node js和vue运行时端口报错

错误信息:

```js

events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES: permission denied C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\BookStore\node_modules\.bin;C:\Users\Samarth's PC\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Samarth's PC\bin;C:\ProgramData\Miniconda3;C:\ProgramData\Miniconda3\Library\mingw-w64\bin;C:\ProgramData\Miniconda3\Library\usr\bin;C:\ProgramData\Miniconda3\Library\bin;C:\ProgramData\Miniconda3\Scripts;C:\Python27;C:\Python27\Scripts;C:\Users\Samarth's PC\AppData\Local\Programs\Python\Python38-32\python.exe;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Yarn\bin;C:\Users\Samarth's PC\AppData\Local\Microsoft\WindowsApps;C:\Program Files\MongoDB\Server\4.0\bin;C:\Program Files\heroku\bin;C:\nvm;C:\Program Files\nodejs;C:\Python 3.8;C:\Users\Samarth's PC\AppData\Roaming\npm;C:\Users\Samarth's PC\AppData\Local\Yarn\bin;C:\Users\Samarth's PC\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
    at Server.setupListenHandle [as _listen2] (net.js:1283:19)
    at listenInCluster (net.js:1348:12)
    at Server.listen (net.js:1447:5)
    at Function.listen (D:\BookStore\node_modules\express\lib\application.js:618:24)
    at Object.<anonymous> (D:\BookStore\app.js:11:5)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1327:8)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  code: 'EACCES',
  errno: 'EACCES',
  syscall: 'listen',
  address: "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\npm-lifecycle\\node-gyp-bin;D:\\BookStore\\node_modules\\.bin;C:\\Users\\Samarth's PC\\bin;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\local\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\mingw64\\bin;C:\\Program Files\\Git\\usr\\bin;C:\\Users\\Samarth's PC\\bin;C:\\ProgramData\\Miniconda3;C:\\ProgramData\\Miniconda3\\Library\\mingw-w64\\bin;C:\\ProgramData\\Miniconda3\\Library\\usr\\bin;C:\\ProgramData\\Miniconda3\\Library\\bin;C:\\ProgramData\\Miniconda3\\Scripts;C:\\Python27;C:\\Python27\\Scripts;C:\\Users\\Samarth's PC\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe;C:\\Program Files\\nodejs;C:\\ProgramData\\chocolatey\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0;C:\\WINDOWS\\System32\\OpenSSH;C:\\Program Files (x86)\\Yarn\\bin;C:\\Users\\Samarth's PC\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\MongoDB\\Server\\4.0\\bin;C:\\Program Files\\heroku\\bin;C:\\nvm;C:\\Program Files\\nodejs;C:\\Python 3.8;C:\\Users\\Samarth's PC\\AppData\\Roaming\\npm;C:\\Users\\Samarth's PC\\AppData\\Local\\Yarn\\bin;C:\\Users\\Samarth's PC\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Program Files\\Git\\usr\\bin\\vendor_perl;C:\\Program Files\\Git\\usr\\bin\\core_perl",
  port: -1
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bookstore@1.0.0 start: `node app.js "app"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bookstore@1.0.0 start script.
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!     C:\Users\Samarth's PC\AppData\Roaming\npm-cache\_logs\2019-12-20T16_43_00_131Z-debug.log

```

解决办法

Hi anyone who comes here and don't find any answer. I have an answer that I think will help. it fixed the issue for me. there is cases where nothing is running on the port but some applications or even your code can not run the fix to this is in this order:

  1. Open PowerShell as Admin.

  2. stop winnat with command below:、

```javascript

$ net stop winnat
```

  1. start winnat again with command below:

```javascript

$ net start winnat
```

this fixed the problem for me in many cases. no restart needed. I hope it will help you too.

Edit: I dig in the problem and found out the problem is the port isn't closed in the right way that could be caused easily based on killing the terminal window or the app running on the port.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值