我写了一个简单的 expressjs 应用程序,它在本地运行得很好,甚至在 no.de 上也能正常运行,但是在 Nodester 上,当我访问http://myapp.nodester.com/时,我得到一个Internal Server Error
并且日志说
Error: failed to locate view "home"
at Function.compile (/node_modules/express/lib/view.js:58:15)
at ServerResponse._render (/node_modules/express/lib/view.js:416:18)
at ServerResponse.render (/node_modules/express/lib/view.js:317:17)
at Router.<anonymous> (/app/server.js:32:6)
at done (/node_modules/express/lib/router/index.js:250:22)
at middleware (/node_modules/express/lib/router/index.js:244:9)
at param (/node_modules/express/lib/router/index.js:227:11)
at pass (/node_modules/express/lib/router/index.js:232:6)
at Router._dispatch (/node_modules/express/lib/router/index.js:255:4)
at Object.handle (/node_modules/express/lib/router/index.js:45:10)
Error: failed to locate view "home"
at Function.compile (/node_modules/express/lib/view.js:58:15)
at ServerResponse._render (/node_modules/express/lib/view.js:416:18)
at ServerResponse.render (/node_modules/express/lib/view.js:317:17)
at Router.<anonymous> (/app/server.js:32:6)
at done (/node_modules/express/lib/router/index.js:250:22)
at middleware (/node_modules/express/lib/router/index.js:244:9)
at param (/node_modules/express/lib/router/index.js:227:11)
at pass (/node_modules/express/lib/router/index.js:232:6)
at Router._dispatch (/node_modules/express/lib/router/index.js:255:4)
at Object.handle (/node_modules/express/lib/router/index.js:45:10)
然后通过 fs 模块,我试图查看它为什么不存在,并fs.readdir('.',function(error,files){console.log(files)})
返回:
[ '.nodester',
'app',
'node_modules',
'usr',
'lib64',
'sbin',
'etc',
'dev',
'proc',
'home',
'bin',
'lib',
'root',
'.PKGINFO',
'.INSTALL' ]
而且我还发现我git push
编辑的所有文件都在apps
目录中。
这是否意味着我必须告诉我views
文件夹所在的正确路径?我怎样才能做到这一点 ?(我只知道如何告诉它以绝对路径呈现文件)。