2014-12-19 55 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/