Error: listen EACCES: permission denied 0.0.0.0:443

Error: listen EACCES: permission denied 0.0.0.0:443

当 运行 npm start 显示此权限问题时。

 Error: listen EACCES: permission denied 0.0.0.0:443
    at Server.setupListenHandle [as _listen2] (node:net:1302:21)
    at listenInCluster (node:net:1367:12)
    at Server.listen (node:net:1454:7)

运行 在 https 端口 443 上带有 npm 的服务器与 sudo 没问题。直到我不得不升级 npm(从 v6 到 v8)。谷歌搜索最初没有帮助,因为每个人都在建议 sudo.

找到重复答案 。 参考another site.

A lot of people get stuck here, but the solution is easy. There a few options but this is the one I like. Type the following commands:

sudo apt-get install libcap2-bin 
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\`` 

Now, when you tell a Node application that you want it to run on port 80, it will not complain.