How to I load a javascript file using express and node.js?

I'm trying to figure out how to load a simple javascript client-side library while using node.js and express. Any ideas? See below.

HAML:

%script{type: 'text/javascript', src: '/jquery-1.4.3.js'} %script{type: 'text/javascript', src: '/client.js'}

app.js:

app.get('/*.js', function(req, res) { res.render(req.params + '.js', { layout: false} ); });

Error:

Error: Cannot find module 'js' at loadModule (node.js:275:15) at require (node.js:411:14) at ServerResponse.render (/usr/local/lib/node/.npm/express/1.0.0rc4/package/lib/express/view.js:289:46) at Object. (/Users/seanbollin/nodemud/app.js:18:7) at pass (/usr/local/lib/node/.npm/connect/0.2.6/package/lib/connect/middleware/router.js:72:27) at Object.router [as handle] (/usr/local/lib/node/.npm/connect/0.2.6/package/lib/connect/middleware/router.js:87:10) at next (/usr/local/lib/node/.npm/connect/0.2.6/package/lib/connect/index.js:264:23) at Object.bodyDecoder [as handle] (/usr/local/lib/node/.npm/connect/0.2.6/package/lib/connect/middleware/bodyDecoder.js:54:13) at next (/usr/local/lib/node/.npm/connect/0.2.6/package/lib/connect/index.js:264:23) at Object.handle (/usr/local/lib/node/.npm/express/1.0.0rc4/package/lib/express/server.js:61:9)

-------------Problems Reply------------

use connect's staticProvider http://senchalabs.github.com/connect/staticProvider.html :)

Category:node.js Views:1 Time:2010-10-22
Tags: node.js

Related post

  • Dynamically load a JavaScript file 2008-08-21

    How can you reliably and dynamically load a JavaScript file? This will can be used to implement a module or component that when 'initialized' the component will dynamically load all needed JavaScript library scripts on demand. The client that uses th

  • How do you dynamically load a javascript file from different domain? 2009-02-27

    I find this excellent code, posted by aemkei as answers to this questions: How do you dynamically load a javascript file? (Think C’s #include) Use javascript to inject script references as needed? You may write dynamic script tags (using Prototype):

  • IE8 Debugger: how to load external javascript files? 2009-10-22

    I have downloaded and installed IE8. I was playing around with the debugger, but I could not figure out how to load external javascript files. It displays the javascript from the main page, but I need to debug the script in the external files. I have

  • Dynamically loading a JavaScript file is different if I use appendChild() or jQuery.append() 2010-01-21

    I am trying to dynamically load a JavaScript file by adding a script element to the head element, after which I test for the presence of a function defined inside that file to check that the load succeeded. If I use this code: var scriptElem = docume

  • Using Prototype to load a JavaScript file from another domain 2010-01-22

    Using Prototype, anyone know how to load a javascript file using Ajax.Request from another domain? Or if this is possible? I believe this is possible with jquery, digg do it to load the Facebook API: jQuery.ajax({type:"GET", url:"http://static.ak.fac

  • Load remote JavaScript files via the address bar 2010-09-18

    Is it possible to load remote JavaScript files from the address bar? I have been trying to put this into the address bar: javascript:src='http://depot.com/file.js';funcname(); I'm not using this for bad things. I'm just testing my site, that's all. I

  • How to load one JavaScript file from another? 2011-05-05

    How do you load one JavaScript file from another JavaScript file, like CSS? In CSS we use write @import url("mycss.css");. Is there any way to do it in JavaScript? --------------Solutions------------- Yes. If you want in pure JavaScript, you have to

  • How do I load a JavaScript file with Jint in C#? 2011-08-14

    I want to load a JavaScript file using Jint, but I can't seem to figure it out. The documentation said I could do something like engine.run(file1), but it doesn't appear to be loading any files. Do I need to do something special with the file name? H

  • Page doesn't load if JavaScript file is missing 2012-03-20

    Im loading a javascript file from a CDN. Im developing locally and I noticed that when my internet went down and the remote file wasn't available, the entire page failed to load. Is there a way of linking to a remote file, but making it so the rest o

  • Loading remote JavaScript file in a page 2010-02-09

    I've a simple page in which in the head I load several remote JavaScript files (I need them and can't have a local copy). The scripts I load are similar to these: <script type="text/javascript" src="http://mymachine/donald/script1.js"></scri

  • can I load a javascript file under a context other than 'window'? 2010-11-08

    I try to load some external .js files, and have some irresolvable namespace conflicts. I had the idea of loading some of the files in their own context somehow, replacing the "this" from pointing at the window object to some custom namespace. example

  • Loading custom JavaScript files in the Wordpress widgets admin panel 2010-11-30

    I'm writing a new Wordpress plugin that includes a widget. The widget configuration options require jQuery code to fetch them from a 3rd party server via JSONP, and attach events so that if one dropdown changes, say category, it dynamically changes t

  • How do I load a javascript file dynamically? 2011-03-08

    I have this code: <script type="text/javascript"> function js() { var getJs = document.getElementById("jogo"); if (JS == true) { //if button JS is pressed - it is correct? < script type = "text/javascript" src = "file1.js" > } else < s

  • Opera won't load some JavaScript files 2011-03-28

    I have a web page that loads in an IFRAME, that runs correctly in IE and Firefox but not in Opera. Which I hate, because I've been an Opera user for years. And I wrote this thing. :-) The problem is that Opera is not loading some of the JavaScript fi

  • Load a Javascript file, but cancel if it takes too long? 2011-04-12

    Anyone have a good way to load a JS file but cancel loading it if it takes too long? I'm thinking something like this, hypothetically: <script type="text/javascript" cancel_after="2000" src="myfile.js"></script> The script is code that ne

  • Disabling loading specific JavaScript files with Firefox 2011-06-09

    I am looking for a way to prevent loading a specific JavaScript file on a website for any website of choice, with Firefox. For example: Say I don't want to load jQuery (when loading the page, not afterwards 'disabling' it). I then want to be able to

  • How to load multiple javascript files inside HTML page 2011-06-16

    I have many js files (say divided into set1 and set2), which are reused in multiple HTML and aspx pages. Using VS 2010. I tried in head of the page1.html < script type="text/javascript" src="/Scripts/set1.js"> < /script> set1.js has: ///

  • Load up javascript files after ajax call 2011-06-26

    Hi how do i go about loading up my javascript files after an ajax call has been made, reason being it seems once i click submit, some javascript functions do not end up working. I tried using "$getscript" however it was a bit buggy especially in goog

  • How to defer loading of JavaScript file? 2011-07-07

    I don't want to call the JavaScript functions at the startup. The reason is simple, it will reduce the initial download size and the page will be appear faster. To do that I used the following code inside head section.. <script type="text/javascri

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.203 (s). 11 q(s)