最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】npm run dev出错:Error listen EADDRINUSE 127.0.0.1:8080

npm crifan 8099浏览 0评论

折腾:

【已解决】preact项目中npm run dev出错:SyntaxError: Unexpected token import

后,出现:

  ucowsapp git:(master) ✗ npm run dev
> [email protected] dev /Users/crifan/dev/dev_root/daryun/Projects/xxx/sourcecode/ucowsapp/ucowsapp
> cross-env NODE_ENV=development webpack-dev-server –inline –hot –progress
10% building modules 1/1 modules 0 activeevents.js:182
      throw er; // Unhandled ‘error’ event
      ^
Error: listen EADDRINUSE 127.0.0.1:8080
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server.setupListenHandle [as _listen2] (net.js:1305:14)
    at listenInCluster (net.js:1353:12)
    at doListen (net.js:1479:7)
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:84:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:100:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server –inline –hot –progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/crifan/.npm/_logs/2017-06-20T03_22_20_795Z-debug.log
➜  ucowsapp git:(master) ✗

别人说的:

原因是:

端口冲突了

方案是:

(1)强杀node进程,然后重新运行,估计就可以了。

(2)改自己的端口

方法是:

(1)更换

/Users/crifan/dev/dev_root/daryun/Projects/xxx/sourcecode/ucowsapp/ucowsapp/webpack.config.babel.js

中的devServer的port中的端口

没去试试,估计可以的。

(2)改运行时配置的端口:

/Users/crifan/dev/dev_root/daryun/Projects/xxx/sourcecode/ucowsapp/ucowsapp/package.json

-》

scripts中的cross-env NODE_ENV=development后面加上:PORT=9090

然后再去:

npm run dev

然后运行输出中,也显示了上述的内容:

> cross-env NODE_ENV=development PORT=9090 webpack-dev-server –inline –hot —progress

然后就可以看到地址:

http://localhost:9090/

对应的页面了:

【后记 2017-06-21】

后来又遇到了:

➜  ucowsapp git:(master) ✗ npm run dev
> [email protected] dev /Users/crifan/dev/dev_root/daryun/Projects/xxx/sourcecode/ucowsapp/ucowsapp
> cross-env NODE_ENV=development webpack-dev-server –inline –hot –progress
10% building modules 1/1 modules 0 activeevents.js:182
      throw er; // Unhandled ‘error’ event
      ^
Error: listen EADDRINUSE 127.0.0.1:8080
    at Object.exports._errnoException (util.js:1026:11)
    at exports._exceptionWithHostPort (util.js:1049:20)
    at Server.setupListenHandle [as _listen2] (net.js:1305:14)
    at listenInCluster (net.js:1353:12)
    at doListen (net.js:1479:7)
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:84:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:100:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server –inline –hot –progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/crifan/.npm/_logs/2017-06-21T02_30_51_815Z-debug.log

然后通过:

➜  ucowsapp git:(master) ✗ ps aux | grep 8080
crifan            8919   0.0  0.0  2495460   1216 s000  S+   一05下午   0:00.06 open -W http://localhost:8080/
crifan           24609   0.0  0.0  2452260    824 s002  S+   10:27上午   0:00.00 grep –color=auto –exclude-dir=.bzr –exclude-dir=CVS –exclude-dir=.git –exclude-dir=.hg –exclude-dir=.svn 8080
➜  ucowsapp git:(master) ✗ kill -9 8919

结果问题依旧:

然后去杀掉另外进程,结果找不到:

➜  ucowsapp git:(master) ✗ ps aux | grep 8080
crifan           24642   0.0  0.0  2432804    764 s002  R+   10:28上午   0:00.00 grep –color=auto –exclude-dir=.bzr –exclude-dir=CVS –exclude-dir=.git –exclude-dir=.hg –exclude-dir=.svn 8080
➜  ucowsapp git:(master) ✗ kill -9 24642
kill: kill 24642 failed: no such process

webpack Error: listen EADDRINUSE 127.0.0.1:8080

Webpack Dev Server Not Working · Issue #8 · bananaoomarang/isomorphic-redux

【总结】

想要杀掉占用了(此处的8080的端口的,所有的node的程序的话,可以)

killall node

然后再去:

npm run dev

即可正常运行了。

转载请注明:在路上 » 【已解决】npm run dev出错:Error listen EADDRINUSE 127.0.0.1:8080

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.173 seconds, using 22.10MB memory