PS Q:\桌面\Sass-practices\client-side> npm start
> client-side@1.0.0 start Q:\桌面\Sass-practices\client-side
> cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js
i 「wdm」: Compiled successfully.
events.js:187
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND loacalhost
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
Emitted 'error' event on Server instance at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1485:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:17) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'loacalhost'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client-side@1.0.0 start: `cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client-side@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! P:\Apps\node-v12.12.0-win-x64\node_cache\_logs\2019-11-13T01_07_18_249Z-debug.log
{
"name": "client-side",
"version": "1.0.0",
"description": "source code of ts-learning",
"main": "./src/index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js"
},
...
}
解决
The most common reason for that error is that you have something else already using that port. Try starting it on another port.
webpack-dev-server --host 127.0.0.1 --port 3001 # in package.json file
Make sure your /etc/hosts file includes localhost.Open /etc/hosts
$ sudo vi /etc/hosts
Copy and paste this, if it’s missing:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost