1. PS Q:\桌\Sass-practices\client-side> npm start
  2. > client-side@1.0.0 start Q:\桌\Sass-practices\client-side
  3. > cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js
  4. i wdm」: Compiled successfully.
  5. events.js:187
  6. throw er; // Unhandled 'error' event
  7. ^
  8. Error: getaddrinfo ENOTFOUND loacalhost
  9. at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
  10. Emitted 'error' event on Server instance at:
  11. at GetAddrInfoReqWrap.doListen [as callback] (net.js:1485:12)
  12. at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:17) {
  13. errno: -3008,
  14. code: 'ENOTFOUND',
  15. syscall: 'getaddrinfo',
  16. hostname: 'loacalhost'
  17. }
  18. npm ERR! code ELIFECYCLE
  19. npm ERR! errno 1
  20. npm ERR! client-side@1.0.0 start: `cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js`
  21. npm ERR! Exit status 1
  22. npm ERR!
  23. npm ERR! Failed at the client-side@1.0.0 start script.
  24. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  25. npm ERR! A complete log of this run can be found in:
  26. npm ERR! P:\Apps\node-v12.12.0-win-x64\node_cache\_logs\2019-11-13T01_07_18_249Z-debug.log
  1. {
  2. "name": "client-side",
  3. "version": "1.0.0",
  4. "description": "source code of ts-learning",
  5. "main": "./src/index.ts",
  6. "scripts": {
  7. "test": "echo \"Error: no test specified\" && exit 1",
  8. "start": "cross-env NODE_ENV=development webpack-dev-server --config ./build/webpack.config.js"
  9. },
  10. ...
  11. }

解决

The most common reason for that error is that you have something else already using that port. Try starting it on another port.

  1. 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

  1. $ sudo vi /etc/hosts

Copy and paste this, if it’s missing:

  1. 127.0.0.1 localhost
  2. 255.255.255.255 broadcasthost
  3. ::1 localhost
  4. fe80::1%lo0 localhost