开发者

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.j开发者_运维百科s: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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜