当我运行以下命令 npx create-react-app my-app
时,我在使用 CRA 创建新的 React 应用程序时遇到问题。
npm cache clean --force
npm -g uninstall create-react-app
我的 node 版本是 v14.15.3
,npm 版本是 7.10.0
我得到的错误是:
Need to install the following packages:
create-react-app
Ok to proceed? (y)
答案 0 :(得分:0)
当它给你这个错误时,它会征求你的许可来安装 create-react-app
...
Ok to proceed? (y)
在终端中输入 y
并按 enter
您可能会发现这也很有帮助: https://create-react-app.dev/docs/getting-started/
<块引用>如果您之前已经通过 npm 全局安装了 create-react-app install -g create-react-app,我们建议您卸载该软件包 使用 npm uninstall -g create-react-app 或 yarn global remove create-react-app 以确保 npx 始终使用最新版本。
答案 1 :(得分:0)
您能否尝试将此路径添加到您的系统变量中?
C:\Users\<user-name>\AppData\Roaming\npm
然后使用 npx create-react-app <app-name>