美文网首页
node-sass 安装失败解决方法

node-sass 安装失败解决方法

作者: 一口一只猫 | 来源:发表于2021-08-25 16:29 被阅读0次

    部署项目时,npm install 出现下图错误

    Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node
    Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node":
    ………………
    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 (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:13:12)
    gyp verb `which` failed     at F (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:68:19)
    gyp verb `which` failed     at E (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:80:29)
    gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:89:16
    gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\index.js:42:5
    gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\windows.js:36:5
    gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21)
    gyp verb `which` failed  python2 Error: not found: python2
    gyp verb `which` failed     at getNotFoundError (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:13:12)
    gyp verb `which` failed     at F (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:68:19)
    gyp verb `which` failed     at E (D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:80:29)
    gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\which\which.js:89:16
    gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\index.js:42:5
    gyp verb `which` failed     at D:\autotest\ebs_atm\ebs-atm-web\node_modules\isexe\windows.js:36:5
    gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:192:21) {
    gyp verb `which` failed   code: 'ENOENT'
    gyp verb `which` failed }
    gyp verb check python checking for Python executable "python" in the PATH
    gyp verb `which` succeeded python D:\Asoftware\python\python.EXE
    gyp ERR! configure error
    gyp ERR! stack Error: Command failed: D:\Asoftware\python\python.EXE -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
    gyp ERR! stack
    gyp ERR! stack     at ChildProcess.exithandler (child_process.js:390:12)
    gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
    gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    gyp ERR! System Windows_NT 10.0.19043
    gyp ERR! command "D:\\Asoftware\\Nodejs\\node.exe" "D:\\autotest\\ebs_atm\\ebs-atm-web\\node_modules\\node-gyp\\bin\\nod
    e-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    gyp ERR! cwd D:\autotest\ebs_atm\ebs-atm-web\node_modules\node-sass
    gyp ERR! node -v v14.17.5
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok
    Build failed with error code: 1
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any
    "} (current: {"os":"win32","arch":"x64"})
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! node-sass@4.12.0 postinstall: `node scripts/build.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the node-sass@4.12.0 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\jingzhou\AppData\Roaming\npm-cache\_logs\2021-08-25T06_41_01_253Z-debug.log
    
    Process finished with exit code 1
    
    Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node
    Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node":
    

    报上图的错误的原因:node-sass模块无法成功下载,并非python的版本问题
    在node_modules文件夹,打开cmd窗口,通过淘宝镜像下载node-sass模块
    命令如下:

    npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
    
    下载成功的图片.png

    ps:由于我的项目的package.json中,版本过低,在下载的时候,自动升级成"^4.14.1"版本


    package.json文件显示.png

    相关文章

      网友评论

          本文标题:node-sass 安装失败解决方法

          本文链接:https://www.haomeiwen.com/subject/qtqeiltx.html