我正在尝试在我的 MacOS 上通过 NodeJS 运行一个 Web 项目。
之后 npm install
, npm start
返回错误
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:443
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1334:19)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Object.<anonymous> (/Users/softtimur/Startup/PRODSERVER/tmp/WeCard/models/www:36:8)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
我的 Mac 上没有其他网站正在运行。
有谁知道出了什么问题?我需要在我的 Mac 上配置一些东西吗?
编辑1:
sudo npm start
返回
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::443
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Object.<anonymous> (/Users/softtimur/Startup/PRODSERVER/tmp/WeCard/models/www:36:8)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
原文由 SoftTimur 发布,翻译遵循 CC BY-SA 4.0 许可协议
为了侦听特权端口,您需要 root 权限才能启动服务器;这适用于端口 < 1024。您可以将 nginx 用作在 443 上运行的反向代理服务器,并以非特权用户身份在非特权端口上运行您的 Node JS 服务器。
有关在生产中使用 nginx 设置 Node JS 应用程序的更多信息,请点击链接: https ://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for- centos-7 上的生产