创建react项目提示error https://registry.yarnpkg.com/......

在创建React应用时遇到yarn下载依赖包失败的问题,错误提示为资源繁忙或锁定。通过更改npm配置,设置下载源为淘宝镜像,解决了因下载源问题导致的安装失败。具体步骤包括:设置npm registry、disturl、删除proxy和https-proxy,以及设置sass-binary-site。重新执行`create-react-app`命令后,成功创建并启动了React项目。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

D:\CidPlat\asdfasdfasfa>create-react-app demo7

Creating a new React app in D:\CidPlat\asdfasdfasfa\demo7.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.19.0
[1/4] Resolving packages...
[2/4] Fetching packages...
error https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.7.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "EBUSY: resource busy or locked, open 'C:\\Users\\fangxin\\AppData\\Local\\Yarn\\Cache\\v5\\npm-es-abstract-1.17.7-a4de61b2f66989fc7421676c1cb9787573ace54c\\node_modules\\es-abstract\\2019\\CompletePropertyDescriptor.js'"
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

^C终止批处理操作吗(Y/N)?
^C

 

思路:每次报错的下载的包名都不一样,而且用的是https://registry.yarnpkg.com,怀疑是下载的源有问题,重新设置下 下载源,步骤如下:

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

npm config set disturl https://npm.taobao.org/dist

npm config rm proxy

npm config rm https-proxy

yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

npm config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

 

然后重新执行:

D:\CidPlat\asdfasdfasfa>create-react-app demo8

Creating a new React app in D:\CidPlat\asdfasdfasfa\demo8.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.19.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.3.1: The platform "win32" is incompatible with this module.
info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.3.2: The platform "win32" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.20.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 7 new dependencies.
info Direct dependencies
├─ cra-template@1.1.2
├─ react-dom@17.0.1
├─ react-scripts@4.0.2
└─ react@17.0.1
info All dependencies
├─ cra-template@1.1.2
├─ react-dev-utils@11.0.2
├─ react-dom@17.0.1
├─ react-error-overlay@6.0.9
├─ react-scripts@4.0.2
├─ react@17.0.1
└─ scheduler@0.20.1
Done in 49.55s.

Initialized a git repository.

Installing template dependencies using yarnpkg...
yarn add v1.19.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.3.2: The platform "win32" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.3.1: The platform "win32" is incompatible with this module.
info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.20.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning " > @testing-library/user-event@12.6.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 17 new dependencies.
info Direct dependencies
├─ @testing-library/jest-dom@5.11.9
├─ @testing-library/react@11.2.5
├─ @testing-library/user-event@12.6.3
├─ react-dom@17.0.1
├─ react@17.0.1
└─ web-vitals@1.1.0
info All dependencies
├─ @testing-library/dom@7.29.4
├─ @testing-library/jest-dom@5.11.9
├─ @testing-library/react@11.2.5
├─ @testing-library/user-event@12.6.3
├─ @types/aria-query@4.2.1
├─ @types/jest@26.0.20
├─ @types/testing-library__jest-dom@5.9.5
├─ css.escape@1.5.1
├─ css@3.0.0
├─ dom-accessibility-api@0.5.4
├─ lz-string@1.4.4
├─ min-indent@1.0.1
├─ react-dom@17.0.1
├─ react@17.0.1
├─ redent@3.0.0
├─ strip-indent@3.0.0
└─ web-vitals@1.1.0
Done in 9.80s.
Removing template package using yarnpkg...

yarn remove v1.19.0
[1/2] Removing module cra-template...
[2/2] Regenerating lockfile and installing missing dependencies...
info fsevents@2.3.2: The platform "win32" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.3.1: The platform "win32" is incompatible with this module.
info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
warning " > @testing-library/user-event@12.6.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.20.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
success Uninstalled packages.
Done in 10.77s.

Created git commit.

Success! Created demo8 at D:\CidPlat\asdfasdfasfa\demo8
Inside that directory, you can run several commands:

  yarn start
    Starts the development server.

  yarn build
    Bundles the app into static files for production.

  yarn test
    Starts the test runner.

  yarn eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd demo8
  yarn start

Happy hacking!

D:\CidPlat\asdfasdfasfa>cd demo8

D:\CidPlat\asdfasdfasfa\demo8>yarn start
yarn run v1.19.0
$ react-scripts start
i 「wds」: Project is running at http://192.168.160.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from D:\CidPlat\asdfasdfasfa\demo8\public
i 「wds」: 404s will fallback to /
Starting the development server...
Compiled successfully!

You can now view demo8 in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.160.1:3000

Note that the development build is not optimized.
To create a production build, use yarn build.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值