错误:ENOENT,在ubuntu上发布应用程序时,没有此类文件或目录'/ var / www / html / views

鬼...

我的nodejs应用程序文件夹结构如下所示。

Index.html文件位于views文件夹内,公用文件夹包含局部页面。

以下是index.html的一小段代码,当节点在计算机上本地运行时,它可以正常工作。

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

在此处输入图片说明

但是,当我在服务器上运行代码时,它给了我错误。

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'))); 
宝ao

Linux使用/目录分隔符,因此无法像使用Windows\分隔符那样找到文件

还请注意,除了Windows之外,Linux区分大小写,因此您需要确保文件名/目录名中的大小写正确。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章