微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决我无法使用 npm 安装任何软件包需要 react-router-dom

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。