欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

npm run dev启动项目报错

程序员文章站 2022-05-13 20:59:55
...

我输入命令 npm run dev之后报这样的错误

> [email protected]1.0.0 dev /Users/zzy/Downloads/projects/mor-brain
> node build/dev-server.js

> Starting dev server...
events.js:177
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8008
    at Server.setupListenHandle [as _listen2] (net.js:1226:14)
    at listenInCluster (net.js:1274:12)
    at Server.listen (net.js:1362:7)
    at Function.listen (/Users/zzy/Downloads/projects/mor-brain/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/Users/zzy/Downloads/projects/mor-brain/build/dev-server.js:85:18)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11
Emitted 'error' event at:
    at emitErrorNT (net.js:1253:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 8008
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected]1.0.0 dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected]1.0.0 dev 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!     /Users/zzy/.npm/_logs/2021-11-01T02_06_10_556Z-debug.log

显示8008端口 地址已经存在

解决方式:
输入命令 lsof -i tcp:8008 查看8008端口对应的pid
再输入 kill pid

再次npm run dev 可以执行成功