npm install 提示 path xxxnode_modulesnode-sass npm ERR command failed 解决方法

41 篇文章 0 订阅

起因

前后经历了多次无法进行 npm install,每次安装依赖都出现类似于 path xxx/node_modules/node-sass npm ERR! command failed 的报错。就因为数次遇到这种错,导致对前端的技术栈有点烦躁,虽然如此,但工作需要,还是要耐心去维护。

自己解决过程:

遇到错误一:
[1/2] scripts.install node-sass@^4.5.2 run “node scripts/install.js”, root: “E:\MyHtmlProcess\online-store
ode_modules\_node-sass@4.14.1@node-sass”
Downloading binary from https://cdn.npmmirror.com/binaries/node-sass/v4.14.1/win32-x64-93_binding.node
***Cannot download “https://cdn.npmmirror.com/binaries/node-sass/v4.14.1/win32-x64-93_binding.node”😗**

***HTTP error 404 Not Found***

Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
gyp verb command configure []
gyp verb download using dist-url https://npmmirror.com/mirrors/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 (E:MyHtmlProcessonline-store ode_modules_which@1.3.1@whichwhich.js:13:12)

注意上面用粗体标注的 :意思是下载node-sass/v4.14.1/win32-x64-93_binding.node
第一个是版本,第二个是 404 没有找到。可能是网络的问题吧,
这个可以到官方网站下载:
可以去GitHub找到node-sass的对应版本:

https://github.com/sass/node-sass/releases
node-sass版本,GitHub
PS:(
一开始报错提示的是无法找到 python2.7 建议设置 PYTHON 环境变量,我特意去安装了一个python2 然后设置环境变量,但却无法解决问题。
第一次我没有注意node-sass 的版本,然后直接就下载了一个win32-x64-102_binding.node, 放到一个目录下,然后设置指定的目录:
set SASS_BINARY_PATH=E:NodeJswin32-x64-102_binding.node,在执行 npm install
接着下面一个报错。

遇到错误二:
Binary found at E:NodeJswin32-x64-102_binding.node
Testing binary
Binary has a problem: Error: The module ‘\E:NodeJswin32-x64-102_binding.node’
was compiled against a different Node.js version using
NODE_MODULE_VERSION 102. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
…此处内容过长
Building the binary locally
Building: E:NodeJs ode.exe E:MyHtmlProcessonline-store ode_modules_node-gyp@3.8.0@node-gypin ode-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= –
gyp verb download using dist-url https://npmmirror.com/mirrors/node
gyp verb check python checking for Python executable “python2” in the PATH
gyp verb `which` failed Error: not found: python2
PS: 这个时候我有重新阅读了一下报的日志信息,意思是我安装的版本不对,让我重新安装93的,我下载的版本问题。同样上面的操作:set SASS_BINARY_PATH=E:NodeJswin32-x64-93_binding.node,在执行 npm install

解决方法:

一开始直接去下载93版本的node-sass, 放到安全目录,set SASS_BINARY_PATH=E:NodeJswin32-x64-93_binding.node, 然后执行 npm install

问题解决。一开始下载404 支援没有找到,我用淘宝镜像安装 cnpm 安装的没有成功。
解决问题的时候,还是注意看根本的报错原因,然后再去操作,不然会走弯路。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值