前言:今天使用 wb 新建 react 项目时,出现如下问题:
提示说明:与 yarn 有关。且与淘宝镜像有关,具体问题报告(log)如下:
vagrant@homestead:~/Code/larabbs$ yarn config set registry https://registry.npm. taobao.org yarn config v0.27.5 success Set "registry" to "https://registry.npm.taobao.org". Done in 1.55s. vagrant@homestead:~/Code/larabbs$ yarn install yarn install v0.27.5 info No lockfile found. [1/4] Resolving packages... warning laravel-mix > img-loader > imagemin-mozjpeg > mozjpeg > bin-wrapper > do wnload > gulp-decompress > gulp-util@3.0.8: gulp-util is deprecated - replace it , following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 [2/4] Fetching packages... warning fsevents@1.1.3: The platform "linux" is incompatible with this module. info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... error An unexpected error occurred: "EPROTO: protocol error, symlink '../acorn/b in/acorn' -> '/home/vagrant/Code/larabbs/nodemodules/acorn-dynamic-import/node modules/.bin/acorn'". info If you think this is a bug, please open a bug report with the information provided in "/home/vagrant/Code/larabbs/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
原因:主要是 yarn 的淘宝镜像问题。
解决:
网上查找解决方法如下:
执行以下命令: 1. yarn config set registry https://registry.npm.taobao.org/ 2. rm -rf /node_modules 3. yarn install --no-bin-links 确认没有错误再往下执行,不然就还得排查错误。 另外,有时候 rm -rf node_modules,重新 yarn install 就可以解决问题,祝好运。
由于博主使用的是 windows 系统,只执行命令1,如下:
yarn config set registry https://registry.npm.taobao.org/
只执行了这句命令,再次创建就成功了。