问题形容?

执行

npm i node-sass -D

关键词形容:

tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 49402 // 这个端口号每个人呈现的可能不一样
Error: Could not find any Python installation to use ...

图形容

如果遇到这些问题,那么在这里应该就能找到答案

最终报的错误信息

为什么有Python的提醒报错

起因:提醒没有装置python、build失败,如果拉取binding.node失败,node-sass会尝试在本地编译binding.node,过程就须要用到python

为什么会下载失败

在执行npm install node-sass的时候,控制台会看到正在从github下载一个win32-x64-72_binding.node的文件,这是一个二进制文件,并不存在npm仓库,而是间接从github下载,下载十分慢,如果本地没有墙过,失败的几率会比拟大

解决下载慢5种办法

  1. 所有的依赖都设置淘宝镜像

    npm config set registry https://registry.npm.taobao.org/
  2. 只对node-sass设置拉取地址

    npm install node-sass --sass-binary-site=https://npm.taobao.org/mirrors/node-sass

    3.在npm config设置

    npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass

    4.在package.json

    "nodeSassConfig": {    "binarySite": "https://npm.taobao.org/mirrors/node-sass"},

    5.在我的项目目录下新建.npmrc文件

    registry=https://registry.npm.taobao.org/# 设置公有服@pm:registry=http://192.168.1.200:8081/repository/npm/
    # 比方装置npm install @pm/axios -Snpm install @pm/vue -S

以上没有解决,解决端口号问题

我的电脑所报的是:49402

查看npm配置

npm config list -l // 查看npm所有配置

查看外面是否代理字段,如有删除

npm config delete proxynpm config delete https-proxy

查看环境变量

在这里发现了一个49402端口,把它删掉

革除环境变量后留神,电脑重启一次

重启之后

到这里做的以上这些查看,或者配置,我曾经解决node-sass装置问题

补充

下载文件至本地办法

目前验证失败

就是先从https://npm.taobao.org/mirrors/node-sass,
选取一个node-sass版本先下载下来,而后在本地npm chche目录中,比方我的电脑的目录

C:\Users\YXS\AppData\Roaming\npm-cache\node-sass

而后设置

npm config set sass-binary-site C:/Users/YXS/AppData/Roaming/npm-cache/node-sass# 查看是否失效npm config list -l

而后装置

npm i node-sass@4.10.0 -D

Windows系操作系统

管理员权限执行以下命令

npm install --global --production windows-build-tools

目前验证失败

长期CMD代理

当前如果须要长期给 cmd 设置代理能够应用以下 命令行,这种环境变量只会继续到cmd窗口敞开,不是零碎环境变量

set http_proxy=http://127.0.0.1:1080set https_proxy=http://127.0.0.1:1080

更有用的常识

https://blog.csdn.net/weixin_38384296/article/details/116403848