先设置成淘宝镜像保证稳定点吧
npm config set registry https://registry.npm.taobao.org 或 npm install -g mirror-config-china
很多时候,npm 安装 node-sass 和 sqlite3 容易出错,无论Linux或Windows,一般如此解决:
我喜欢用yarn,设置
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
如果用npm,下面的就用npm来安装
yarn global add node-pre-gyp
yarn global add node-gyp
可能提示还需要装 python2.7
或许需要 npm install --global --production windows-build-tools
或者 npm config set msvs_version 2017
具体可以参考 node-pre-gyp 和 node-gyp 的 github
有时候可能需要手动编译 npm rebuild node-sass 或者源码编译
npm install sqlite3 --build-from-source
补充:
某次 yarn 的时候, node-sass 还是遇到一样的 gyp ERR! 相关编译错误,最后解决办法是:
先 yarn remove node-sass 然后再 yarn add node-sass