yarn install一直卡在Building fresh packages...

小感触 2020年02月16日 378次浏览

为前端项目安装依赖的时候,出现以下问题,卡顿很久,然后提示网络超时....

QQ截图20200216120327.png

解决办法:

  • 项目下新建文件:.npmrc或.yarnrc(npm安装建立.npmrc)文件。
  • 直接在windows资源管理器无法直接建立上述仅有扩展名的文件,需要在IDE里面建立。
  • 在建立的文件输入以下内容:
registry "https://registry.npm.taobao.org"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"

再次运行yarn install 即可快速完成安装过程:

info fsevents@1.2.9: The platform "win32" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > vue-loader@15.7.2" has unmet peer dependency "css-loader@*".
warning " > vue-loader@15.7.2" has unmet peer dependency "webpack@^4.1.0 || ^5.0.0-0".
warning " > less-loader@4.1.0" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning " > sass-loader@7.3.1" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
warning " > html-webpack-plugin@4.0.0-beta.11" has unmet peer dependency "webpack@^4.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 10.38s.