npm install 报错 not found: python2
主要错误信息
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError FSReqWrap.oncomplete (fs.js:153:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python anaconda3/bin/python
gyp ERR! configure error
gyp ERR! stack Error: Command failed: anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3]
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
出现改错误是因为跟本没有找到python2指令
可以设置一下 npm install时候使用那个python
由于我是mac,本地有python和python2.7
所以运行npm install的时候把python带上,如下
npm install --python=python2.7
or
npm install --python=python