2015-10-02 16 views
1

我的nodejs應用程序文件夾結構如下所示。錯誤:ENOENT,沒有這樣的文件或目錄'/ var/www/html /視圖,而在ubuntu上發佈應用程序

Index.html文件位於views文件夾中,公用文件夾包含partials頁面。

下面是index.html中的一小段代碼,當節點在本地機器上運行時,它工作正常。

<section id="sidebar" ng-controller="menuController" ng-init="init()"> 
    <% include ..\public\partials\_menubar.html %> 
</section> 

enter image description here

但是當我運行在服務器上的代碼,它給我的錯誤。

Error: ENOENT, no such file or directory   
'/var/www/html/views/..\public\partials\_menubar.html' 
at Object.fs.openSync (fs.js:432:18) 
at Object.fs.readFileSync (fs.js:286:15) 
at includeSource (/var/www/html/node_modules/ejs/lib/ejs.js:194:17) 
at /var/www/html/node_modules/ejs/lib/ejs.js:528:26 
at Array.forEach (native) 
at Object.Template.generateSource (/var/www/html/node_modules/ejs/lib/ejs.js:505:15) 
at Object.Template.compile (/var/www/html/node_modules/ejs/lib/ejs.js:427:12) 
at Object.compile (/var/www/html/node_modules/ejs/lib/ejs.js:288:16) 
at handleCache (/var/www/html/node_modules/ejs/lib/ejs.js:147:16) 
at View.exports.renderFile [as engine]  (/var/www/html/node_modules/ejs/lib/ejs.js:350:14) 

我試過使用下面的代碼,但沒有成功。

app.use(express.static(path.join(__dirname, 'public'))); 
+1

linux使用'/'作爲目錄分隔符。你正在使用Windows'\\' – baao

+1

你真棒@baao請寫下我接受的答案 –

回答

2

Linux使用/作爲目錄分隔符,以便你使用的是Windows' \分離器中的文件的無法找到。

另請注意,除了windows以外,linux是區分大小寫的,因此您需要確保在文件/目錄名中包含正確的大小寫。

相關問題