在Mac上npm install报错

2,976 阅读1分钟

都是node.js版本太高的原因,可以降低版本

// 首先安装n模块
sudo npm install -g n

// 升级到任意版本
sudo n v8.12.0

// 查看node.js版本
node -v

// 使用 下载依赖指令
npm install

继续报错
报错信息

// 提示 fis3 模块不存在

解决

// 使用最高权限
sudo npm xxx xxx

如果不降低版本到话,就参考以下步骤

vscode 运行 npm install 报错

错误信息

> node-sass@4.5.3 install /Users/xxxxxxx/Documents/store/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/darwin-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/darwin-x64-72_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. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> node-sass@4.5.3 postinstall /Users/xxxxx/Documents/store/node_modules/node-sass
> node scripts/build.js

解决

sudo npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose

cnpm install

运行

sudo npm run xxx