On macOS Mojave 10.14.3, I encountered a similar error that was resolved by running
$ pyenv shell 3.7.1 2.7.15
I encountered this issue trying to run $ npx create-react-app my_app --use-npm
on a system where yarn is installed and being used by default. Note, without --use-npm
, when yarn was the package manager used and there was no error.
Here is the error raised by --use-npm
that was resolved by $ pyenv shell 3.7.1 2.7.15
> [email protected] install /Users/richardlogwood/dev/react/my_app/node_modules/fsevents
> node install
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/richardlogwood/.pyenv/shims/python2 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack pyenv: python2: command not found
gyp ERR! stack
gyp ERR! stack The `python2' command exists in these Python versions:
gyp ERR! stack 2.7.15
gyp ERR! stack
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:188:13)
gyp ERR! stack at maybeClose (internal/child_process.js:978:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:395:11)
gyp ERR! stack at Socket.emit (events.js:188:13)
gyp ERR! stack at Pipe._handle.close (net.js:610:12)
gyp ERR! System Darwin 18.2.0
. . .
More details about the solution:
$ pyenv versions
system
2.7.15
* 3.7.1 (set by /Users/richardlogwood/.pyenv/version)
$ pyenv shell 3.7.1 2.7.15
$ pyenv versions
system
* 2.7.15 (set by PYENV_VERSION environment variable)
* 3.7.1 (set by PYENV_VERSION environment variable)
$ pyenv shell
3.7.1:2.7.15
# now create-react-app succeeds!
npx create-react-app my_app --use-npm
I was led to this solution for my problem by this GitHub issue https://github.com/electron-userland/electron-builder/issues/638
python
will be python2 andpython3
will be python3. – Mercury