2
我试图将一个Node.js应用程序部署到弹性beanstalk。问题是,它每次都在启动脚本中失败。我将ec2配置为使用启动脚本npm start
,它执行node app.js
(在package.json中定义)。但是,此启动脚本在ec2中失败。我得到记录的错误,Elastic Beanstalk在启动脚本失败
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myProject start script 'node app.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Portfolio package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs myProject
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls myProject
npm ERR! There is likely additional logging output above.
这是什么意思?在我的命令行上运行npm start
的压缩到AWS的同一应用的根目录中工作正常,在本地主机上运行。我也已经更新两NPM和Node.js的
这里是文件结构拉链部署:
.ZIP
- node_modules/
- 公共/
- app.js
- package.json
- package-lock.json
您是否找到解决方法? –
是的。首先,确保你的项目所依赖的所有npm依赖项都存在于'package.json'文件中。然后将终端或命令行中的目录切换到您的项目的根目录并运行'npm install',这将确保您的'node_modules'文件夹填充有'package.json'文件指定的正确依赖关系。看到[这个问题](https://stackoverflow.com/questions/8367031/how-do-i-install-package-json-dependencies-in-the-current-directory-using-npm)获得更多帮助! –