我无法使用 npm 安装任何软件包(需要 react-router-dom)

时间:2020-12-25 10:53:15

标签: node.js reactjs npm npm-install yarnpkg

当我一开始尝试安装某些东西时,我看到一些乱码,而且花费的时间太长,最后它给了我一个错误。最重要的是 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 之类的东西。

1 个答案:

答案 0 :(得分:0)

运行这些命令(按顺序):

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