[英]Cannot create a React app with create-react-app
I am facing a problem with creating a new React app using CRA when I run the following command npx create-react-app my-app
.当我运行以下命令npx create-react-app my-app
时,我遇到了使用CRA创建新 React 应用程序的问题。
npm cache clean --force
我尝试使用此命令清除 npm 缓存npm cache clean --force
npm -g uninstall create-react-app
我也试过这个命令npm -g uninstall create-react-app
My node version is v14.15.3
and the npm version is 7.10.0
我的节点版本是v14.15.3
,npm 版本是7.10.0
The error which I get is:我得到的错误是:
Need to install the following packages:
create-react-app
Ok to proceed? (y)
Need to clear the cache on the npx:需要清除npx上的缓存:
npx clear-npx-cache
and then re-run然后重新运行
npx create-react-app <app-name>
and then accept (y)然后接受 (y)
Just had the same problem.刚遇到同样的问题。 This worked for me:这对我有用:
Just clear the cache by running, npx clear-npx-cache
and then try to create your react app npx creact-react-app my-app
.只需通过运行 npx clear-npx npx clear-npx-cache
,然后尝试创建您的反应应用程序npx creact-react-app my-app
。
When it said Ok to proceed? (y)
当它说Ok to proceed? (y)
Ok to proceed? (y)
I went through that twice and it told me the version I was using was no longer supported so, npm update
Ok to proceed? (y)
我经历了两次,它告诉我我使用的版本不再受支持,所以npm update
Hi Oussama Bouchikhi,嗨,乌萨马·布奇基,
You can try the following npm
commands to solve the issue:您可以尝试以下npm
命令来解决问题:
Run this first,先运行这个,
npm uninstall -g create-react-app
then然后
npm install -g create-react-app
Here's the snapshot of the same, create-react-app-issue这是相同的快照, create-react-app-issue
Let us know if it works!让我们知道它是否有效! Happy Hacking!快乐黑客!
When it gives you this error, it asks your permission to install create-react-app
当它给你这个错误时,它会询问你是否允许安装create-react-app
...
Ok to proceed? (y)
Type y
in your terminal and press enter
在终端中输入y
并enter
You might find this helpful as well: https://create-react-app.dev/docs/getting-started/您可能会发现这也很有帮助: https://create-react-app.dev/docs/getting-started/
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.如果您之前通过 npm install -g create-react-app 全局安装了 create-react-app,我们建议您使用 npm 卸载 package 以确保卸载应用程序那 npx 总是使用最新版本。
could you try to add this path to your system variable?您可以尝试将此路径添加到您的系统变量吗? C:\Users\<user-name>\AppData\Roaming\npm
and try again with npx create-react-app <app-name>
然后再试一次npx create-react-app <app-name>
there appears to be a package that is compromising security.似乎有一个 package 损害了安全性。
You need to clear your npx cache first.您需要先清除 npx 缓存。
Delete the folder _npx
inside the path returned by npm config get cache
删除npm config get cache
返回的路径内的文件夹_npx
# In Linux/MacOS terminal
rm -rf `npm config get cache`/_npx
This can also be done with @snewn's method , I posted this in case you want to skip that dependency.这也可以使用@snewn 的方法来完成,我发布了这个以防您想跳过该依赖项。
Need to clear the cache on the npx:需要清除npx上的缓存:
npx clear-npx-cache and then re-run npx clear-npx-cache 然后重新运行
npx create-react-app and then accept (y) npx create-react-app 然后接受 (y)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.