npm run dev 报getaddrinfo ENOTFOUND localhost
【摘要】 问题npm run dev报错getaddrinfo ENOTFOUND localhost,原因是127.0.0.1 没有和localhost绑定。yarn run v1.22.19$ viteserve developmentbuild.terserOptions is specified but build.minify is not set to use Terser. Note ...
问题
npm run dev
报错getaddrinfo ENOTFOUND localhost
,原因是127.0.0.1 没有和localhost绑定。
yarn run v1.22.19
$ vite
serve development
build.terserOptions is specified but build.minify is not set to use Terser. Note Vite now defaults to use esbuild for minification. If you still prefer Terser, set build.minify to "terser".
error when starting dev server:
Error: getaddrinfo ENOTFOUND localhost
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:internal/dns/promises:42:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
解决方案
- 打开hosts文件
sudo vim /etc/hosts
- 在文件末尾输入下面
127.0.0.1 localhost
- esc 退出编辑
- wq 保存
- 重启项目,即可正常运行
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)