npm 启动时出现 webpack-dev-server 错误

webpack-dev-server error on npm start

我正在尝试 运行 在 ng2-admin 上启动 npm,一切正常,直到我死了 npm update 以尝试更新包,

之后 npm 启动并出现错误:

webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/
10% building modules 3/3 modules 0 activeError: listen EADDRINUSE 127.0.0.1:8080
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at Server._listen2 (net.js:1257:14)
at listen (net.js:1293:10)
at net.js:1403:9
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)
npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/vm/versions/node/v6.9.1/bin/node" node/v6.9.1/bin/npm" "run" "server:dev"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! ng2-admin@0.7.0 server:dev: webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ng2-admin@0.7.0 server:dev script 'webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ng2-admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --config config/webpack.

错误消息的相关部分是:listen EADDRINUSE 127.0.0.1:8080。这意味着 webpack-dev-server 正在 127.0.0.1:8080 上尝试 运行,但地址和端口已被使用。

尝试打开浏览器并在地址栏中输入 127.0.0.1:8080。也许该端口上已经有另一台服务器 运行ning。 运行 jobs 检查后台进程。

将 package.json 中的依赖项更改为

"webpack-dev-server": "2.1.0-beta.10", 而不是像

"webpack-dev-server": "^2.1.0-beta.9",

运行 npm install 或 npm update 之后。