解决办法:

改用国内镜像

如果想临时使用国内镜像

npm install node-sass --registry=http://registry.npm.taobao.org


如果想永久改成国内镜像

npm config set registry https://registry.npm.taobao.org


如果想要查询当前使用的npm配置

npm config list可以查询当前是否已经修改了镜像源


但是有时候使用国内镜像还是会出现下载超时的问题,可以通过清除缓存后再次尝试

npm cache clean --force


如果这种清除缓存的方式还不行可以试试大招

1、删除npmrc文件,删除C:\Users\Administrator.npmrc文件

2、 C:\Users\Administrator\AppData\Roaming\npm-cache 清空,

3、删除项目下:node_modules

4、用命令清理,控制台输入:

npm cache clean --force


PS:如果无法删除node_modules模块可以通过以下方式尝试删除


3. 安装npm包-> rimraf

npm install rimraf -g

4. 在控制台进入node_modules上级目录

rimraf node_modules

谨慎使用,别删错其他东西了!


如果通过删除缓存还没办法成功install,可以尝试npm降级

npm -g i npm@4


通过还是失败,可以通过cnpm下


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

cnpm install 成功~~~~

cnpm和npm的指令基本一致,如果需要用到npm的指令可以通过cnpm代替!


点赞(186)

评论列表共有 0 条评论

立即
投稿
返回
顶部