npm 创建反应应用程序等待很长时间后无法完成



任何人都可以帮助我为什么npm在我的windows计算机上创建react应用程序无法完成?虽然我等了好几个小时,但它总是以这样的方式结束,而且从未完成安装。

C:UsersBestDesktop>npx create-react-app my-app
npx: installed 98 in 44.022s
Creating a new React app in C:UsersBestDesktopmy-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

> core-js@2.6.11 postinstall C:UsersBestDesktopmy-appnode_modulesbabel-run
timenode_modulescore-js
> node -e "try{require('./postinstall')}catch(e){}"

> core-js@3.6.5 postinstall C:UsersBestDesktopmy-appnode_modulescore-js
> node -e "try{require('./postinstall')}catch(e){}"

> core-js-pure@3.6.5 postinstall C:UsersBestDesktopmy-appnode_modulescore-
js-pure
> node -e "try{require('./postinstall')}catch(e){}"
+ react@16.13.1
+ react-scripts@3.4.1
+ cra-template@1.0.3
+ react-dom@16.13.1
added 1602 packages from 751 contributors and audited 1606 packages in 668.379s
61 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
  1. 从控制面板清理节点缓存或卸载节点js并确保将其删除,尤其是从windows注册表中删除,因为即使在卸载后,也可能有一些全局包和依赖项会导致此问题。(这主要发生在linux上(

2(从其官方网站安装node-js(LTS版本(和yarn因为你需要node在终端中运行js,而yarn(和react(是由facebook开发的,用于解决node包管理器的问题

3(

npx create-react-app new-app
or
yarn create react-app new-app

更改目录并键入npx-start,通过localhost运行您的示例应用程序

还有另一个命令来构建react应用程序,也许它能解决你的问题。

npx create-react-app

注意写npx而不是npm。

此问题可能是由命令提示符失速引起的。按照以下步骤继续该过程。

运行npx create-react-app my-app后应遵循以下步骤

Steps:
1) Search for resource monitor in windows search
2) Go to CPU tab
3) Search for cmd.exe
4) Right click on it
5) Click on Resume Process.

谢谢

使用yarn而不是npm更容易,创建反应应用的时间更少

yarn create react-app my-app 

文档链接https://create-react-app.dev/docs/getting-started/#yarn

如果有任何疑问,请在这里评论

这里是React的资源:创建React应用

摘要:

  1. 请确保您已经安装了最新版本的节点
  2. 确保sample目录不存在
  3. 打开一个终端,然后运行此命令npx create-react-app sample

我遇到了类似的问题,我通过以下命令设置npm代理来解决它:

npm config set proxy http://your-organization-proxy
npm config set https-proxy http://your-organization-proxy
npm config set proxy your, organization, no, proxy, urls

请确保在代理URL中保留http://

过了很长时间,我下载了Nodejs32位。难以置信的是,这就是诀窍。

最新更新