错误:找不到模块' /opt/repo/ROOT/server.js

时间:2017-03-02 01:55:34

标签: javascript node.js git express jelastic

jelastic node.log文件

上的

server.js错误

我正在尝试使用bootstrapnodejs express发布简单ejs页面,但服务器正在说504 Gateway timeout并且无法运行它。此外,nodejs log文件显示如下错误:

Thu Mar 02 2017 01:26:47 GMT+0000 (UTC): Starting application 'nodejs' ... npm info it worked if it ends with ok npm info using npm@3.6.0 npm info using node@v5.6.0 npm info lifecycle DrawingGame@0.0.1~prestart: DrawingGame@0.0.1 npm info lifecycle DrawingGame@0.0.1~start: DrawingGame@0.0.1  > DrawingGame@0.0.1 

start /opt/repo/ROOT > node server.js  
Thu Mar 02 2017 01:28:55 GMT+0000 (UTC): Stopping application 'nodejs' ... 

Thu Mar 02 2017 01:28:55 GMT+0000 (UTC): Stopped Node application 'nodejs' Thu Mar 02 2017 01:28:55 GMT+0000 (UTC): Starting application 'nodejs' ... Script = server.js Script Args =  Node Options =  module.js:341 throw err; ^  Error: Cannot find module '/opt/repo/ROOT/server.js' at Function.Module._resolveFilename (module.js:339:15) at Function.Module._load (module.js:290:25) at Function.Module.runMain (module.js:447:10) at startup (node.js:140:18) at node.js:1001:3 Thu Mar 02 2017 01:32:04 GMT+0000 (UTC): Starting application 

'nodejs' ... Script = server.js Script Args =  Node Options =  module.js:341 

throw err; ^  

Error: Cannot find module '/opt/repo/ROOT/server.js' 

at Function.Module._resolveFilename (module.js:339:15) at Function.Module._load (module.js:290:25) at Function.Module.runMain (module.js:447:10) at startup (node.js:140:18) at node.js:1001:3

我的简单代码位于 GitHub https://github.com/penjav/metse

我跟随turotrial:https://docs.jelastic.com/nodejs-git-svn

但没有运气。请指导我。并告诉我错误。 非常感谢你。

1 个答案:

答案 0 :(得分:2)

由于项目结构不正确,发生了此错误。 NodeJS部署脚本期望找到文件" server.js"或" package.json"在根目录中,但在这种情况下,这些文件不会放在那里(它们放在子目录中)。

您需要更改项目结构并重新部署项目。