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 [email protected]
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 [email protected]
npm ERR! gyp info using [email protected] | 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. (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 [email protected]
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 [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported

> [email protected] 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

> [email protected] 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 -)


> [email protected] 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


> [email protected] postinstall D:\yuwei-workspacke\test-node\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js


> [email protected] 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: [email protected] (node_modules\webpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
updated 1425 packages in 81.248s

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

总结

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

你可能感兴趣的:(npm,node-sass错误)