安装node-sass失败的解决方案

前言

        今天安装node-sass安装失败包错误截取为:

npm ERR! code 1
npm ERR! path D:\前端学习\网课\5阶段\code\11 工程化开发\webpack_base_use\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\前端学习\\网课\\5阶段\\code\\11 工程化开发\\webpack_base_use\\node_modules\\node-gyp\\bin\\node-gyp.js',       
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.6.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - "python" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python2" can be used
npm ERR! gyp verb find Python - executing "python2" to get executable path
npm ERR! gyp verb find Python - "python2" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if Python is C:\Python37\python.exe
npm ERR! gyp verb find Python - executing "C:\Python37\python.exe" to get version
npm ERR! gyp verb find Python - "C:\Python37\python.exe" could not be run
npm ERR! gyp verb find Python checking if Python is C:\Python27\python.exe
npm ERR! gyp verb find Python - executing "C:\Python27\python.exe" to get version
npm ERR! gyp verb find Python - "C:\Python27\python.exe" could not be run
npm ERR! gyp verb find Python checking if the py launcher can be used to find Python
npm ERR! gyp verb find Python - executing "py.exe" to get Python executable path
npm ERR! gyp verb find Python - "py.exe" is not in PATH or produced an error
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python2" can be used
npm ERR! gyp ERR! find Python - "python2" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if Python is C:\Python37\python.exe
npm ERR! gyp ERR! find Python - "C:\Python37\python.exe" could not be run
npm ERR! gyp ERR! find Python checking if Python is C:\Python27\python.exe
npm ERR! gyp ERR! find Python - "C:\Python27\python.exe" could not be run
npm ERR! gyp ERR! find Python checking if the py launcher can be used to find Python
npm ERR! gyp ERR! find Python - "py.exe" is not in PATH or produced an error
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "C:\Path\To\python.exe"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (D:\前端学习\网课\5阶段\code\11 工程化开发\webpack_base_use\node_modules\node-gyp\lib\find-python.js:302:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (D:\前端学习\网课\5阶段\code\11 工程化开发\webpack_base_use\node_modules\node-gyp\lib\find-python.js:136:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\前端学习\网课\5阶段\code\11 工程化开发\webpack_base_use\node_modules\node-gyp\lib\find-python.js:200:18)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (D:\前端学习\网课\5阶段\code\11 工程化开发\webpack_base_use\node_modules\node-gyp\lib\find-python.js:266:16)
npm ERR! gyp ERR! stack     at exithandler (node:child_process:404:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:416:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:480:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19042

        查了百度的解决方案只能说是完全不适合当下的情况——没用

        在其官网上才找到了解决方法:

        Install from mirror in China

npm install -g mirror-config-china --registry=http://registry.npm.taobao.org
npm install node-sass

        实测有用, 希望我以后查问题第一个就能想到官网而不是百度吧。 

        安装复制在终端等待一会就行了

 

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
【用于解决 failed Error: not found: python2 node-sass】 报错信息如下: ``` npm WARN prefer global [email protected] should be installed with -g > node-sass@4.5.2 install E:\workspace_vscode\ww\node_modules\node-sass > node scripts/install.js Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5 .2/win32-x64-48_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.2/win3 2-x64-48_binding.node": connect ETIMEDOUT 54.231.72.83: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.5.2 postinstall E:\workspace_vscode\ww\node_modules\node-sass > node scripts/build.js 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 ``` 这个问题有两个解决方案 1. 按照提示需要 python2 环境,安装python2环境确实可以解决, 网上好多这种(管理员身份执行)。但是当你本来就有python环境时,环境变量不能自动替换,整起来就很麻烦。 ``` npm install --global --production windows-build-tools ``` 2. 第二种解决方案 ,看另一句报错,资源被墙。 ``` Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.2/win32-x64-48_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.2/win32-x64-48_binding.node": ``` 下载此资源即可。下载后需要设置变量路径,防止它再次去下载。 可以设置环境变量 直接右键我的电脑--》属性--》高级系统设置--》环境变量--》添加 或者执行 ``` set SASS_BINARY_PATH=D:\nodejs\tools\node-sass\win32-x64-46_binding.node ``` 再次执行 npm install 成功

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Heigl swift

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值