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)獲得更多幫助! –