zoukankan      html  css  js  c++  java
  • node-sass安装失败之npm ERR! Failed at the node-sass@4.9.4 postinstall script.

    一个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 ode_moduleswhichwh
    ich.js:13:12)
    gyp verb `which` failed at F (E:souhu1 ode_moduleswhichwhich.js:68:19)
    gyp verb `which` failed at E (E:souhu1 ode_moduleswhichwhich.js:80:29)
    gyp verb `which` failed at E:souhu1 ode_moduleswhichwhich.js:89:16
    gyp verb `which` failed at E:souhu1 ode_modulesisexeindex.js:42:5
    gyp verb `which` failed at E:souhu1 ode_modulesisexewindows.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 ode_moduleswhichwh
    ich.js:13:12)
    gyp verb `which` failed at F (E:souhu1 ode_moduleswhichwhich.js:68:19)
    gyp verb `which` failed at E (E:souhu1 ode_moduleswhichwhich.js:80:29)
    gyp verb `which` failed at E:souhu1 ode_moduleswhichwhich.js:89:16
    gyp verb `which` failed at E:souhu1 ode_modulesisexeindex.js:42:5
    gyp verb `which` failed at E:souhu1 ode_modulesisexewindows.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 at getNotFoundError (
    E:\souhu1\node_modules\which\which.js:13:12) at F (E:\souhu1\node_mod
    ules\which\which.js:68:19) at E (E:\souhu1\node_modules\which\which.j
    s:80:29) at E:\souhu1\node_modules\which\which.js:89:16 at E:\sou
    hu1\node_modules\isexe\index.js:42:5 at E:\souhu1\node_modules\isexe
    windows.js:36:5 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 ode_moduleswhichwh
    ich.js:13:12)
    gyp verb `which` failed at F (E:souhu1 ode_moduleswhichwhich.js:68:19)
    gyp verb `which` failed at E (E:souhu1 ode_moduleswhichwhich.js:80:29)
    gyp verb `which` failed at E:souhu1 ode_moduleswhichwhich.js:89:16
    gyp verb `which` failed at E:souhu1 ode_modulesisexeindex.js:42:5
    gyp verb `which` failed at E:souhu1 ode_modulesisexewindows.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 ode_moduleswhichwh
    ich.js:13:12)
    gyp verb `which` failed at F (E:souhu1 ode_moduleswhichwhich.js:68:19)
    gyp verb `which` failed at E (E:souhu1 ode_moduleswhichwhich.js:80:29)
    gyp verb `which` failed at E:souhu1 ode_moduleswhichwhich.js:89:16
    gyp verb `which` failed at E:souhu1 ode_modulesisexeindex.js:42:5
    gyp verb `which` failed at E:souhu1 ode_modulesisexewindows.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 at getNotFoundError (E
    :\souhu1\node_modules\which\which.js:13:12) at F (E:\souhu1\node_modu
    les\which\which.js:68:19) at E (E:\souhu1\node_modules\which\which.js
    :80:29) at E:\souhu1\node_modules\which\which.js:89:16 at E:\souh
    u1\node_modules\isexe\index.js:42:5 at E:\souhu1\node_modules\isexe\
    windows.js:36:5 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:Python27python.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 ode_modules ode-gyp
    libconfigure.js:484:19)
    gyp ERR! stack at PythonFinder.<anonymous> (E:souhu1 ode_modules ode-gyp
    libconfigure.js:509:16)
    gyp ERR! stack at E:souhu1 ode_modulesgraceful-fspolyfills.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 ode_modules ode-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 ode_modules ode-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:UsersAdministratorAppDataRoaming pm ode_modulescnpmlibpar
    se_argv.js)
    npm@6.4.1 (C:UsersAdministratorAppDataRoaming pm ode_modulescnpm ode_mod
    ules pmlib pm.js)
    node@10.13.0 (D:Program Files odejs ode.exe)
    npminstall@3.16.0 (C:UsersAdministratorAppDataRoaming pm ode_modulescnpm
    node_modules pminstalllibindex.js)
    prefix=C:UsersAdministratorAppDataRoaming pm
    win32 x64 6.1.7601
    registry=https://registry.npm.taobao.org
     最后执行我的gulp,编译成功

    E:souhu1>gulp
    [01:14:46] Using gulpfile E:souhu1gulpfile.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] 编译: srcscssaichuanshi.css
    [01:14:46] 编译: srcscsscontribute.css
    [01:14:46] 编译: srcscssdetail.css
    [01:14:47] 编译: 0 items
    [01:14:47] Finished 'script' after 311 ms
    [01:14:47] 编译: srcscssindex.css
    [01:14:47] 编译: srcscsslist.css
    [01:14:47] 编译: srcscssmain.css
    [01:14:47] 编译: srcscss iuchuanshi.css
    [01:14:47] 编译: srcscsspersonData.css
    [01:14:47] 编译: srcscss egist.css
    [01:14:47] 编译: srcscssserverList.css
    [01:14:47] 编译: srcscssserverList1.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

  • 相关阅读:
    C#实现京东登录密码加密POST
    查询SQL Server数据库所有表字段备注
    DataGridView数值列和日期列
    (转)Android 系统 root 破解原理分析
    Dynamics AX 中重点数据源方法
    .NET中Debug模式与Release模式
    DotNetBar的初步使用
    省市区联动小功能
    多余的Using Namespaces或引用会影响程序的执行效率么?
    MSIL指令集
  • 原文地址:https://www.cnblogs.com/ldsweely/p/15046493.html
Copyright © 2011-2022 走看看