问题描述
当我一开始尝试安装某些东西时,我看到一些乱码,而且花费的时间太长,最后它给了我一个错误。最重要的是 Yarn 没有帮助。
npm version 6.14.10,node v14.15.1,yarn v * 1.22.10
当我尝试使用 yarn 安装时,我看到了这个乱码。
yarn add v1.22.10
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "C:\\Users\\DavrService™\\AppData\\Local\\Yarn\\Cache\\v6\\npm-hoist-non-react-statics-3.3.2-ece0acaf71d62c2969c2ec59feff42a4b1a85b45-integrity\\node_modules\\hoist-non-react-statics\\.yarn-Metadata.json: Unexpected token \u0000 in JSON at position 0".
info If you think this is a bug,please open a bug report with the information provided in "D:\\real\\test\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
当我尝试使用 npm 时,它会显示 npm warn deprecated
之类的东西。
解决方法
运行这些命令(按顺序):
npm cache clear -force
npm uninstall -g create-react-app
npm i -g create-react-app
npm i -g npm
npx create-react-app myapp