Node.js在Linux中使用80端口報錯
由于伺服器用的CentOS8,為便于開發部署将本地環境換為了Linux。
使用SVN将項目檢出配置完成執行
npm run dev
時報錯:
FATAL listen EACCES: permission denied 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1296:21)
at listenInCluster (net.js:1361:12)
at doListen (net.js:1498:7)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
✖ Nuxt Fatal Error
Error: listen EACCES: permission denied 0.0.0.0:80
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxx dev:
nuxt
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xxx.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/xxx/.npm/_logs/xxx-debug.log
![]()
Node.js在Linux中使用80端口報錯Node.js在Linux中使用80端口報錯
解決方案
一開始懷疑時80端口被占用了,但檢視端口資訊後發現80并沒有被占用,那應該就是沒有使用80端口的權限了。簡單的處理辦法就是加
sudo
提權。
将
npm run dev
換成
sudo npm run dev