node-sass安装失败番外篇

node-sass安装失败番外篇

工作 环境

win10 ,npm 使用淘宝镜像源

错误现象

报错信息如下:

我在不同电脑的不同 编辑器(webstom, vscdoe ,cmd, git bash) 下显示的错误不太一样

可能如下错误: https://npm.taobao.org/mirrors/node-sass/v4.14.1/win32-x64-88_binding.node 404 ,点开网址确实找不到,在相应目录下找不到对应 node文件

kyle@DESKTOP-LIPAM5T MINGW64 /d/yuwei-workspacke/test-node
$ npm install node-sass@4.14.1
npm ERR! code 1
npm ERR! path D:\yuwei-workspacke\test-node\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@15.3.0 | win32 | x64
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "C:/Program Files/Git/path/to/executable/python2.7", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:\yuwei-workspacke\test-node\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\yuwei-workspacke\test-node\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack     at callback (D:\yuwei-workspacke\test-node\node_modules\graceful-fs\polyfills.js:295:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:192:21)
npm ERR! gyp ERR! System Windows_NT 10.0.18363
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\yuwei-workspacke\\test-node\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:\yuwei-workspacke\test-node\node_modules\node-sass
npm ERR! gyp ERR! node -v v15.3.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kyle\AppData\Local\npm-cache\_logs\2020-11-25T12_02_49_917Z-debug.log

原因

node 版本使用的最新版,而不是 LTS 版本

kyle@DESKTOP-LIPAM5T MINGW64 /d/yuwei-workspacke/test-node
$ nvm list

  * 15.3.0 (Currently using 64-bit executable)
    12.16.1
    12.10.0

切换 LTS 版本 后, 显然安装成功

kyle@DESKTOP-LIPAM5T MINGW64 /d/yuwei-workspacke/test-node
$ nvm use 12.16.1
Now using node v12.16.1 (64-bit)

kyle@DESKTOP-LIPAM5T MINGW64 /d/yuwei-workspacke/test-node
$ npm install node-sass@4.14.1
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported

> node-sass@4.14.1 install D:\yuwei-workspacke\test-node\node_modules\node-sass
> node scripts/install.js

Cached binary found at C:\Users\kyle\AppData\Roaming\npm-cache\node-sass\4.14.1\win32-x64-72_binding.node

> core-js@2.6.11 postinstall D:\yuwei-workspacke\test-node\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> swiper@4.5.1 postinstall D:\yuwei-workspacke\test-node\node_modules\swiper
> node -e "console.log('\u001b[35m\u001b[1mLove Swiper? Support Vladimir\'s work by donating or pledging on patreon:\u001b[22m\u001b[39m\n > \u001b[32mhttps://patreon.com/vladimirkharlampidi\u001b[0m\n')"      

Love Swiper? Support Vladimir's work by donating or pledging on patreon:
 > https://patreon.com/vladimirkharlampidi


> uglifyjs-webpack-plugin@0.4.6 postinstall D:\yuwei-workspacke\test-node\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js


> node-sass@4.14.1 postinstall D:\yuwei-workspacke\test-node\node_modules\node-sass
> node scripts/build.js

Binary found at D:\yuwei-workspacke\test-node\node_modules\node-sass\vendor\win32-x64-72\binding.node
Testing binary
Binary is fine
npm WARN The package less is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\webpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ node-sass@4.14.1
updated 1425 packages in 81.248s

7 packages are looking for funding
  run `npm fund` for details

总结

在工作使用一定要使用 LTS 版本,不然折腾(同事用的,我一般都是 稳定版)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值