我正在阅读官方的React教程,希望使用自己的文本编辑器;因此,我按照他们的指示进行操作,一直到通过“ npx create-react-app my-app”创建我的应用程序为止。然后,当我运行命令“ npm start”时,我得到以下信息:
(base) Benjamins-MacBook-Pro:my-app solidiquis$ npm start
my-app@0.1.0 start /Users/solidiquis/Desktop/my-app
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.
Learn more here: **omitted
events.js:173
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:26)
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1440:12) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:58:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@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/solidiquis/.npm/_logs/2019-03-23T20_04_34_120Z-debug.log
(base) Benjamins-MacBook-Pro:my-app solidiquis$
我已经卸载并重新安装了多个节点;我还尝试过在项目的根目录中添加.env文件,如下所述: npm start on new create-react-app build returns ELIFECYCLE error,但无济于事。任何帮助将不胜感激!
答案 0 :(得分:0)
很奇怪,但对我有用
转到
控制面板->系统和安全性->系统->高级系统 安全性->环境变量
在“环境变量”弹出窗口中,您将编辑用户变量PATH并将“ C:\ Windows \ System32” 值添加为以分号分隔的现有值。
但并非最不重要的是重新启动计算机。
答案 1 :(得分:-1)
对我来说,这是因为HOST变量设置为“ x86_64-apple-darwin13.4.0”。这里的步骤帮助我解决了这个问题:https://medium.com/@choy/fixing-create-react-app-when-npm-fails-to-start-because-your-host-environment-variable-is-being-4c8a9fa0b461