首页 前端知识 项目 npm run dev报错

项目 npm run dev报错

2024-05-23 20:05:07 前端知识 前端哥 342 339 我要收藏

1、报错内容

Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
Emitted 'error' event on Server instance at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1500:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:17) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'localhost'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

2、解决方法:

(1)尝试更改版本,nvm use 14.17.0,更改后 还是报错

(2)打开config文件夹下的index.js文件找到如下图这段代码:

    host: 'localhost', // can be overwritten by process.env.HOST  ipv6配置'[::1]'
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

host 修改为 127.0.0.1

转载请注明出处或者链接地址:https://www.qianduange.cn//article/9208.html
标签
评论
发布的文章

用JS生成本周日期代码

2024-04-18 17:04:15

js 递归函数

2024-05-31 10:05:46

jQuery是什么?如何使用?

2024-03-12 01:03:24

js延迟加载的六种方式

2024-05-30 10:05:51

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!