首页 > 编程语言 >npm 安装 node-sass 失败问题分析及解决方案

npm 安装 node-sass 失败问题分析及解决方案

时间:2022-12-09 15:45:58浏览次数:53  
标签:npm node sass work modules js verb gyp

在使用npm 安装依赖时,执行到

Missing binding E:\webstorm\notepad\notepad\node_modules\node-sass\vendor\win32-x64-46\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 10.x

时报错,下载node-sass时无响应;

下面是部分错误信息:

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-64_binding.node":
 
ESOCKETTIMEDOUT
 
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
 
> [email protected] postinstall D:\work\xiangmu\heb-metro-operator-page\node_modules\@babel\polyfill\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:\work\xiangmu\heb-metro-operator-page\node_modules\babel-polyfill\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
 
 
> [email protected] postinstall D:\work\xiangmu\heb-metro-operator-page\node_modules\babel-runtime\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
 
 
> [email protected] postinstall D:\work\xiangmu\heb-metro-operator-page\node_modules\core-js
> node postinstall || echo "ignore"
 
 
> [email protected] postinstall D:\work\xiangmu\heb-metro-operator-page\node_modules\core-js-pure
> node postinstall || echo "ignore"
 
 
> [email protected] postinstall D:\work\xiangmu\heb-metro-operator-page\node_modules\ejs
> node ./postinstall.js
 
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
 
 
> [email protected] postinstall D:\work\xiangmu\heb-metro-operator-page\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:\work\xiangmu\heb-metro-operator-page\node_modules\node-sass
> node scripts/build.js
 
Building: C:\Program Files\nodejs\node.exe D:\work\xiangmu\heb-metro-operator-page\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'D:\\work\\xiangmu\\heb-metro-operator-page\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
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:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\work\xiangmu\heb-metro-operator-page\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\work\xiangmu\heb-metro-operator-page\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:153:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\work\xiangmu\heb-metro-operator-page\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\work\xiangmu\heb-metro-operator-page\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\work\xiangmu\heb-metro-operator-page\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:153:21)

分析了好久,没有找到原因,后来注意到了下载地址是github 的文件地址,突然想起来github文件下载缓慢或无响应,于是试着解决了下,发现问题居然消失了;
下面贴我的解决方法:

第一步,打开本机上的Hosts文件

首先,什么是Hosts文件?

在互联网协议中,host表示能够同其他机器互相访问的本地计算机。一台本地机有唯一标志代码,同网络掩码一起组成IP地址,如果通过点到点协议通过ISP访问互联网,那么在连接期间将会拥有唯一的IP地址,这段时间内,你的主机就是一个host。
在这种情况下,host表示一个网络节点。host是根据TCP/IP for Windows 的标准来工作的,它的作用是包含IP地址和Host name(主机名)的映射关系,是一个映射IP地址和Host name(主机名)的规定,规定要求每段只能包括一个映射关系,IP地址要放在每段的最前面,空格后再写上映射的Host name主机名 。对于这段的映射说明用“#”分割后用文字说明。

Hosts文件的路径是:

C:\Windows\System32\drivers\etc

由于文件没有后缀名,可以利用鼠标右键点击,选择用记事本打开

第二步,追加域名的IP地址

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
 
10.170.1.149 windows10.microdone.cn

保存。

第三步,刷新 DNS 缓存

在终端或CMD中,执行以下命令:

ipconfig /flushdns

之后再重新安装依赖就ok了。

标签:npm,node,sass,work,modules,js,verb,gyp
From: https://www.cnblogs.com/ZerlinM/p/16969094.html

相关文章

  • k8s 节点node维护
    1、设置节点不可调度kubectlcordonnode02设置node02不可调度,查看各节点状态,发现node02为SchedulingDisabled,此时master不会将新的pod调度到该节点上,但是node02上pod还是正......
  • node 的管理 nvm
    可以通过以下命令,进行node版本的安装,替换nvmlist//查看已安装的nodejs版本nvmon//启用node.js版本管理nvmoff//禁用node.js版本管理(不卸载任何东......
  • 【win10】Typora+PicGo+node+gitee配置图床
    文章目录​​前言​​​​1.giitee设置​​​​设置私人令牌​​​​2.PicGo设置​​​​PicGo安装及安装环境配置​​​​配置PicGo​​​​设置日志文件​​​​配置git......
  • nvm:npm版本管理
    官方下载链接运行安装包,首先选择nvm安装目录,然后设置Node.js的Symlink,即需要设置nodejs的快捷方式存放的目录,可以是"D:\nodejs_nvm"命令行输入nvm查看是否安装成功n......
  • 【1】认识NodeJS
    1、什么是NodeJS?大家都知道,JavaScript是运行在浏览器上的脚本语言,简称JS,代码由浏览器解释后执行。JS不能脱离浏览器运行在服务器上,但NodeJS把JS的战场从浏览器转移到......
  • 针对前端项目node版本问题导致依赖安装异常的处理办法
    Mac如何切换版本​前端项目开发过程中,多人开发会遇到由于node版本不同造成的依赖不适配。比如: node16.xx大多都会遇到依赖版本与node版本不适配导致安装报错等问题,并且......
  • websocket(二)——基于node js 的同步聊天应用
     ​​https://github.com/sitegui/nodejs-websocket​​1.用node搭建本地服务npminstallnodejs-websocket varws=require("nodejs-websocket");varserver=ws.cr......
  • day1:node安装+项目创建
    一、安装node1、http://nodejs.cn/download/中文网下载node工具,直接下一步式的安装。二、验证安装1、win+r 输入cmd,分别运行一下,node-v  npm-v ......
  • 在linux环境中安装node,npm,express
    linux安装node连接运程命令:进入usr/local文件夹cd/usr/local1.下载wgethttps://nodejs.org/dist/v14.17.6/node-v14.17.6-linux-x64.tar.xz2.解压tarxvf......
  • Windows10 gitbook本地搭建(nodejs v10.23.0)
    1.下载Nodejs并安装,默认路径即可。(用最新的版本没成功,按照一篇博客里提示的版本nodejsv10.23.0,成功创建gitbook)https://nodejs.org/download/release/v10.23.0/node-v1......