问题
安装React脚手架时使用yarn create react-app my app命令显示如下错误。
engguilideMacBook-Pro:textApp zengguili$ yarn create react-app myapp
yarn create v1.22.19
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
success Installed "create-react-app@5.0.1" with binaries:
- create-react-app
Creating a new React app in /Users/zengguili/textapp/myapp.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.22.19
info No lockfile found.
[1/4] 🔍 Resolving packages...
//省略若干代码
Error: Couldn't find package "postcss-value-parser@^4.2.0" required by "postcss-overflow-shorthand@^3.0.4" on the "npm" registry.
//省略若干代码
Error: Couldn't find package "postcss-value-parser@^4.1.0" required
Deleting generated file... package.json
Deleting myapp/ from /Users/zengguili/textapp
Done.
error Command failed.
Exit code: 1
Command: /Users/zengguili/.yarn/bin/create-react-app
Arguments: myapp
Directory: /Users/zengguili/textapp
Output:
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.
解决办法
用yarn cache clean
命令清除缓存
cengguilideMacBook-Pro:textApp zengguili$ yarn cache clean
yarn cache v1.22.19
success Cleared cache.
✨ Done in 9.68s.
再重新运行:yarn create react-app myapp