Fixing create-react-app when npm fails to start because your host environment variable is being set incorrectly
My Mac’s host environment variable was set to
x86_64-apple-darwin13.4.0. Seems like others have problems with it being set like this too.
$ env | grep HOST
npm startto fail in my Create React App folder.
Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
Emitted 'error' event at:
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1498:12)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! firstname.lastname@example.org start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! Failed at the email@example.com start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This makes sense to me. My mac’s chip architecture and os (Darwin) aren’t network hosts. Maybe something else needs this variable set this way? I don’t know. To be safe, I set up a local environment variable.
To fix the problem,
- I wrote
~.bash_profilevia my command line editor of choice
- I “reloaded” the environment variables with
And now, npm is happy for create-react-app.
Maybe this will save someone else some time, or maybe someone will suggest a better way to deal with this or explain to me why my HOST was set as such. Or, maybe, this will just be another useful note to self.