一个npm install报了一堆问题

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 getNotFoundError (E:\souhu1\node_modules\which\wh
ich.js:13:12)
gyp verb `which` failed at F (E:\souhu1\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\souhu1\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\souhu1\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\souhu1\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\souhu1\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\souhu1\node_modules\which\wh
ich.js:13:12)
gyp verb `which` failed at F (E:\souhu1\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\souhu1\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\souhu1\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\souhu1\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\souhu1\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2\n at getNotFoundError (
E:\\souhu1\\node_modules\\which\\which.js:13:12)\n at F (E:\\souhu1\\node_mod
ules\\which\\which.js:68:19)\n at E (E:\\souhu1\\node_modules\\which\\which.j
s:80:29)\n at E:\\souhu1\\node_modules\\which\\which.js:89:16\n at E:\\sou
hu1\\node_modules\\isexe\\index.js:42:5\n at E:\\souhu1\\node_modules\\isexe\
\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed at getNotFoundError (E:\souhu1\node_modules\which\wh
ich.js:13:12)
gyp verb `which` failed at F (E:\souhu1\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\souhu1\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\souhu1\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\souhu1\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\souhu1\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed python { Error: not found: python
gyp verb `which` failed at getNotFoundError (E:\souhu1\node_modules\which\wh
ich.js:13:12)
gyp verb `which` failed at F (E:\souhu1\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\souhu1\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\souhu1\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\souhu1\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\souhu1\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python\n at getNotFoundError (E
:\\souhu1\\node_modules\\which\\which.js:13:12)\n at F (E:\\souhu1\\node_modu
les\\which\\which.js:68:19)\n at E (E:\\souhu1\\node_modules\\which\\which.js
:80:29)\n at E:\\souhu1\\node_modules\\which\\which.js:89:16\n at E:\\souh
u1\\node_modules\\isexe\\index.js:42:5\n at E:\\souhu1\\node_modules\\isexe\\
windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at PythonFinder.failNoPython (E:\souhu1\node_modules\node-gyp
\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (E:\souhu1\node_modules\node-gyp\
lib\configure.js:509:16)
gyp ERR! stack at E:\souhu1\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "E:\\souhu1\\node_modules
\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_
cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\souhu1\node_modules\node-sass
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN gulpexample@1.0.0 No description
npm WARN gulpexample@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.4 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.4 postinstall script.
问题:找不到python2,node-sass安装失败

尝试解决办法:先去安装一个python2,记得一定要安装paython2,因为paython2和python3不兼容。

 

安装记得勾选图中模块,不然python -v 测试会报以下报错

E:\souhu1>python -v
'python' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
 安装python2再执行一遍npm install,node-sass还是安装失败

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9
.4/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.9.4/win3
2-x64-64_binding.node":

connect ETIMEDOUT 52.216.225.176:443

Timed out whilst downloading the prebuilt binary

Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.

export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

npm config set proxy http://example.com:8080

> node-sass@4.9.4 postinstall E:\souhu1\node_modules\node-sass
> node scripts/build.js
错误提示太多,截取开始的一部分,根据ETIMEDOUT关键字百度一下,说的是github在国内不稳定,可以用代理,或者用淘宝的镜像,其实上面的报错的代码提示连接超时建议使用代理,不过我最后选择了淘宝的镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org
安装完成执行一个cnpm -v测试一下,看到下面的执行结果那就是安装完成了,接下来就是cnpm install一次,操作cnpm和npm一样,只是把 npm替换成cnpm,建议把之前生成的node_modules包删除一下,再重新生成,避免一些不必要的错误。

E:\souhu1>cnpm -v
cnpm@6.0.0 (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cnpm\lib\par
se_argv.js)
npm@6.4.1 (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cnpm\node_mod
ules\npm\lib\npm.js)
node@10.13.0 (D:\Program Files\nodejs\node.exe)
npminstall@3.16.0 (C:\Users\Administrator\AppData\Roaming\npm\node_modules\cnpm\
node_modules\npminstall\lib\index.js)
prefix=C:\Users\Administrator\AppData\Roaming\npm
win32 x64 6.1.7601
registry=https://registry.npm.taobao.org
 最后执行我的gulp,编译成功

E:\souhu1>gulp
[01:14:46] Using gulpfile E:\souhu1\gulpfile.js
[01:14:46] Starting 'html'...
[01:14:46] Starting 'font'...
[01:14:46] Starting 'sass'...
[01:14:46] Starting 'images'...
[01:14:46] Starting 'plug'...
[01:14:46] Starting 'script'...
[01:14:46] Starting 'sprite'...
[01:14:46] Finished 'font' after 53 ms
[01:14:46] 编译: src\scss\aichuanshi.css
[01:14:46] 编译: src\scss\contribute.css
[01:14:46] 编译: src\scss\detail.css
[01:14:47] 编译: 0 items
[01:14:47] Finished 'script' after 311 ms
[01:14:47] 编译: src\scss\index.css
[01:14:47] 编译: src\scss\list.css
[01:14:47] 编译: src\scss\main.css
[01:14:47] 编译: src\scss\niuchuanshi.css
[01:14:47] 编译: src\scss\personData.css
[01:14:47] 编译: src\scss\regist.css
[01:14:47] 编译: src\scss\serverList.css
[01:14:47] 编译: src\scss\serverList1.css
[01:14:47] 编译: 11 items
[01:14:47] Finished 'html' after 609 ms
[01:14:47] Finished 'sass' after 595 ms
[01:14:47] Finished 'plug' after 590 ms
[01:14:48] gulp-imagemin: Minified 0 images
[01:14:48] Finished 'images' after 2.2 s
[01:14:56] gulp-imagemin: Minified 1 image (saved 55.9 kB - 10.1%)
[01:14:56] Finished 'sprite' after 9.55 s
[01:14:56] Starting 'default'...
[01:14:56] Starting 'webserver'...
[01:14:56] Webserver started at http://:::8888
[01:14:56] Finished 'webserver' after 19 ms
[01:14:56] Starting 'watch'...
[01:14:56] Finished 'watch' after 317 ms
[01:14:56] Finished 'default' after 340 ms
 最后,网络不好的时候,建议把npm换成cnpm,这样可以快速解决问题。

原文链接:https://blog.csdn.net/luoyu19940615/article/details/84504644
————————————————

如果还是不行,可以尝试卸载重新安装node-sass

1、卸载node-sass 

运行:npm uninstall node-sass

 

2、重新安装指定的node-sass版本(安装失败的版本)

运行:npm install node-sass@4.9.0

 

node-sass 安装失败 Failed at the node-sass@4.9.2 postinstall script.

https://blog.csdn.net/u013253924/article/details/81025994

posted on 2020-02-14 19:09  liuruyi007  阅读(2988)  评论(0编辑  收藏  举报