我在基于node.js的亚马逊网络服务上设置了一个Elastic Beanstalk实例,并试图让它运行harp.js。
它在Heroku上用这个Procfile运行得很好:web: harp server --port $PORT
但在亚马逊网络服务上,没有Procfile (据我所知),所以我将根目录中的package.json文件更改为:
{
"name": "Marketing-Website",
"version": "1.0.0",
"description": "My App",
"dependencies": {
"harp": "*"
},
"scripts": {
"start": "harp server --port 80"
}
}这似乎不起作用。在服务器日志中,我最终得到:
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
npm ERR! If you do, this is most likely a problem with the Marketing-Website package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! harp server --port 80
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Marketing-Website
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Marketing-Website
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
> Marketing-Website@1.0.0 start /var/app/current
> harp server --port 80
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:80
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at Server._listen2 (net.js:1249:19)
at listen (net.js:1298:10)
at net.js:1408:9
at _combinedTickCallback (internal/process/next_tick.js:83:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3
npm ERR! Linux 4.9.85-38.58.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.12.2-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.12.2-linux-x64/bin/npm" "start"
npm ERR! node v6.12.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! Marketing-Website@1.0.0 start: `harp server --port 80`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Marketing-Website@1.0.0 start script 'harp server --port 80'.
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 Marketing-Website package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! harp server --port 80
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Marketing-Website
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Marketing-Website
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
> Marketing-Website@1.0.0 start /var/app/current
> harp server --port 80
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:80
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at Server._listen2 (net.js:1249:19)
at listen (net.js:1298:10)
at net.js:1408:9
at _combinedTickCallback (internal/process/next_tick.js:83:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3当我在没有--port 80的情况下运行它时,网站建立了,但我在根网站上得到了502错误网关错误。我转到了我认为是默认端口的地方,它在我身上超时了。
发布于 2018-04-10 05:04:08
您需要以root访问权限运行它才能使用端口80
您可以将启动脚本更改为:
"scripts": {
"start": "sudo harp server --port 80"
}https://stackoverflow.com/questions/49697427
复制相似问题