使用create-react-app创建了一个新的react应用程序,现在在运行npm start时在终端中出现以下错误:
> react-scripts start
Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
If this was unintentional, check that you haven't mistakenly set it in your shell.
events.js:167
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1468:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aqi@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aqi@0.1.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! /Users/chris/.npm/_logs/2018-12-24T10_07_46_970Z-debug.log
尝试删除node-module文件夹和npm安装。
在终端中键入
我为这个问题纠结了一整天。如果您做了
- 之后,保存文件并退出(Command+q)/li>
- 最后,通过在终端上键入以下内容重新加载环境:
如果您正确执行了所有步骤,这应该可以解决bug。
我也纠结于此。很多在线解决方案只解决了第一部分。在这里,我将提供我的方法来完全解决这个问题,并使npm开始工作
了解问题:
这个问题有两个部分。首先,您希望将环境变量HOST设置为“localhost"。您可以通过输入您的终端(任何地方)来完成此操作:
现在,您的计算机已将其主机变量更新为localhost。您可以通过在终端中键入:
希望这能彻底解决问题。如果随后遇到:
这仅仅意味着这些人出了问题。为什么?我不确定,但一个确定的解决办法是从搜索中删除node_modules/fsevent文件。一个永久性的修复方法是删除节点模块并重新安装npm。确保fsevent是2.0+版本!
希望能帮上忙。这肯定花了一些时间来调试!
参考资料: