使用Yarn创建React项目遇到的问题

不知道小伙伴们在使用yarn,创建react项目时有没有遇到过如下问题:

yarn create react-app antd-demo
yarn create v1.17.3
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "[email protected]" with binaries:
      - create-react-app
[############################################################################################] 92/92
Creating a new React app in H:\React\demo.

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

yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1". Got "10.8.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts --cwd H:\React\antd-demo has failed.

Deleting generated file... package.json
Deleting antd-demo/ from H:\React
Done.
error Command failed.
Exit code: 1
Command: C:\Users\YWL\AppData\Local\Yarn\bin\create-react-app
Arguments: antd-demo
Directory: H:\React
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
PS H:\React> yarn start
yarn run v1.17.3
error Couldn't find a package.json file in "H:\\React"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

解决办法,运行如下命令,然后重新运行:

 yarn config set ignore-engines true

你可能感兴趣的:(使用Yarn创建React项目遇到的问题)