首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我运行npx创建反应应用程序我的应用程序时出错

当我运行npx创建反应应用程序我的应用程序时出错
EN

Stack Overflow用户
提问于 2021-12-29 14:29:58
回答 5查看 2.9K关注 0票数 1

我已经尝试过这两个命令,并且得到了相同的错误。

代码语言:javascript
复制
npm clean cache --force
npx create-react-app client -timeout=120000


$ npx create-react-app client -timeout=120000
npm WARN exec The following package was not found and will be installed: create-react-app
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

Creating a new React app in C:\web_dev\MERN\projects\booking-app\client.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network request to https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz failed, reason: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\web_dev\MERN\projects\booking-app\tmpnodejsnpm-cache\_logs\2021-12-29T13_37_03_989Z-debug-0.log

Aborting installation.
  npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting client/ from C:\web_dev\MERN\projects\booking-app
Done.
EN

回答 5

Stack Overflow用户

发布于 2022-02-19 14:11:16

我刚刚在更新一个旧项目时也遇到了同样的问题。在我的案子中,解决的是:

如果使用yarn,则

代码语言:javascript
复制
yarn global remove create-react-app
yarn cache clean

如果使用npm,则

代码语言:javascript
复制
npm remove create-react-app
npx clear-npx-cache

另外,请确保目录中没有创建新React项目的文件夹,因为您可以得到另一个类似于以下内容的警告:

代码语言:javascript
复制
The directory . contains files that could conflict:

  <the file(s) name here>/

Either try using a new directory name, or remove the files listed above.

在那之后,npx create-react-app .跑得很顺利。

上述步骤解决了以下后续警告(版本可能有所不同):

  1. 全球预警

代码语言:javascript
复制
You are running "create-react-app" 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.

  1. 焦油警告

代码语言:javascript
复制
tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
票数 1
EN

Stack Overflow用户

发布于 2022-05-29 07:12:15

甚至我也得到了同样的错误,然后看到你的问题,我关闭了所有的任务,并运行这个命令"npx创建-反应-应用程序我的应用程序“,它再次解决了!

票数 1
EN

Stack Overflow用户

发布于 2021-12-29 14:39:25

我也有同样的问题,所以我在全球范围内卸载它,然后重新安装:-

create-react-app

  • npm卸载create-react-app

  • npm卸载-g

然后我用npx:-

  • npx创建反应应用项目-app

告诉我这个对你有用吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70520786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档