2014-12-19 53 views
0

我正在使用自动生成的布局从快车发电机简单的节点/快递应用.js文件产生404是'gauge-main.js'文件。快递JS对于明显存在

这个文件是在我的“index.jade”文件引用,位于“/观点”目录:

extends layout 

block head 
     head 
       meta(charset='utf-8') 
       title Index 
       link(rel='stylesheet', href='/stylesheets/gauge-index.css', type='text/css', media='screen', charset='utf-8') 
block body 
     body 
       script(src='/public/javascripts/gauge-main.js', type='text/javascript', charset='utf-8') 

当应用程序被运行一些“*的.css”文件是否正确链接,但的“计-main.js”产生一个404错误:

> [email protected] start /srv/node/ase 
> node ./bin/www 

GET/200 231.694 ms - 424 
GET /stylesheets/style.css 200 4.683 ms - 110 
Warning: Unexpected block "content" on line 3 of /srv/node/ase/views/error.jade. This block is never used. This warning will be an error in v2.0.0 
GET /public/javascripts/gauge-main.js 404 12.587 ms - 154 
GET /stylesheets/gauge-index.css 200 13.849 ms - 155 
GET /stylesheets/gauge-simple.css 200 2.074 ms - 1025 
GET /stylesheets/gauge-small.css 200 1.919 ms - 1014 
GET /stylesheets/gauge-grayscale.css 200 1.857 ms - 1039 
Warning: Unexpected block "content" on line 3 of /srv/node/ase/views/error.jade. This block is never used. This warning will be an error in v2.0.0 
GET /favicon.ico 404 10.821 ms - 154 
Warning: Unexpected block "content" on line 3 of /srv/node/ase/views/error.jade. This block is never used. This warning will be an error in v2.0.0 
GET /favicon.ico 404 6.519 ms - 154 

顺便说一句,请忽略其他404的图标。

我认为,因为'* .css'文件使用相对路径('/ stylesheets/...')正确链接,所以'gauge-main.js'的情况也是如此以相同的方式链接('/javascripts/gauge-main.js')。

任何想法?

回答

4

我的猜测是你在做app.use(express.static(__dirname + '/public'));因为你的css被正确的服务。因此,您需要做的是将脚本的src值更改为/javascripts/而不是/public/javascripts/