运行vue项目getaddrinfo ENOTFOUND localhost错误

Ali*_* HI 0 npm yarnpkg nuxt.js

我已经初始化了一个nuxt项目,当我尝试使用npm run dev或yarn dev命令运行它时,它会返回以下错误:

    build [==================  ] 91%Error: getaddrinfo ENOTFOUND localhost
    at errnoException (dns.js:50:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
error Command failed with exit code 1.
Run Code Online (Sandbox Code Playgroud)

知道它来自哪里?

小智 8

将127.0.0.1 localhost添加到/ etc/hosts