Javascript elastic beanstalk如何运行nodejs应用程序代码?

Javascript elastic beanstalk如何运行nodejs应用程序代码?,javascript,node.js,amazon-web-services,express,amazon-elastic-beanstalk,Javascript,Node.js,Amazon Web Services,Express,Amazon Elastic Beanstalk,我的应用程序在localhost中运行正常,但当我将其提交到其他地方(如aws(或mcs))部署时,它无法识别lib委托方加载路由所需的文件路径 这就是我希望运行的: > portal@1.0.0 start /home/code/tmp/portal > NODE_ENV=development nodemon index.js [nodemon] 1.11.0 [nodemon] to restart at any time, enter `rs` [nodemon] watc

我的应用程序在localhost中运行正常,但当我将其提交到其他地方(如aws(或mcs))部署时,它无法识别lib委托方加载路由所需的文件路径

这就是我希望运行的:

> portal@1.0.0 start /home/code/tmp/portal
> NODE_ENV=development nodemon index.js

[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
consign v0.1.2 Initialized in app
+ ./controllers/homeController.js
+ ./routes/routes.js
Ok! Express is running...
以下跟踪是aws发生的情况,请查看它是否无法识别homeController.js文件:

> portal@1.0.0 start /var/app/current
> NODE_ENV=development nodemon index.js

[nodemon] 1.11.0[39m
[nodemon] to restart at any time, enter `rs`[39m
[nodemon] watching: *.*[39m
[nodemon] starting `node index.js`[39m
consign v0.1.2 Initialized in app
+ ./current/
+ ./current/
/var/app/current/app/routes/routes.js:2
    app.get('/',         app.controllers.homeController.index.bind(app.controllers.homeController)); 
                            ^

TypeError: Cannot read property 'homeController' of undefined
    at Function.module.exports (/var/app/current/app/routes/routes.js:2:33)
at Consign.into (/var/app/current/node_modules/consign/lib/consign.js:239:17)
at Object.<anonymous> (/var/app/current/config/express.js:18:6)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/app/current/index.js:1:80)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
[31m[nodemon] app crashed - waiting for file changes before starting...[39m
>portal@1.0.0开始/var/app/current
>NODE_ENV=development nodemon index.js
[nodemon]1.11.0[39米
[nodemon]要随时重新启动,请输入'rs`[39m]
[nodemon]观看:**.*[39米
[nodemon]正在启动'node index.js`[39m
交付在应用程序中初始化的v0.1.2
+/当前/
+/当前/
/var/app/current/app/routes/routes.js:2
get('/',app.controllers.homeController.index.bind(app.controllers.homeController));
^
TypeError:无法读取未定义的属性“homeController”
在Function.module.exports(/var/app/current/app/routes/routes.js:2:33)
在authoit.into(/var/app/current/node_modules/authoit/lib/authoit.js:239:17)
at对象。(/var/app/current/config/express.js:18:6)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
at Module.require(Module.js:497:17)
根据需要(内部/module.js:20:19)
at对象。(/var/app/current/index.js:1:80)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
位于Module.runMain(Module.js:604:10)
运行时(bootstrap_node.js:394:7)
启动时(bootstrap_node.js:149:9)
在bootstrap_node.js:509:3
[31m[nodemon]应用程序崩溃-在启动之前等待文件更改…[39m]
你知道为什么这个环境会干扰这个应用程序路径吗?
或者aws如何运行此代码?

发生此问题的原因是委托库的行为。aws使用的路径被视为错误,因为它包含字符串“app”(/var/current/app/)


我使用整个路径修复了它(process.cwd()+'/app').

…很明显,
app
在第2行的/var/app/current/app/routes/routes.js文件中没有定义。从那里开始你的研究。EBS根据你的设置启动EC2服务器。你应该能够以这样的方式配置它,你可以通过ssh连接到服务器并从那里查看事情。不过……你部署它似乎有点奇怪升级服务器并使用nodemon作为启动/运行服务器的方式。nodemon不是一个开发工具吗?