繁体   English   中英

然后尝试 create-react-app 时出错(npm ERR!cb() never call!然后尝试 create-react-app)

[英]Error then trying create-react-app( npm ERR! cb() never called! then trying create-react-app)

遇到一些麻烦,然后尝试创建反应应用程序

PS D:\Projects\Test> npx create-react-app my-app

Creating a new React app in D:\Projects\Test\my-app.

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

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\semen\AppData\Roaming\npm-cache\_logs\2022-01-05T05_29_35_153Z-debug.log

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

我重新安装了几次nodejs。 将 nodejs 降级到 14.18.1 版本。 尝试使用纱线。 但是这种解决方案在我的情况下不起作用。 我使用 Windows 10。感谢您的帮助!

创建 React 应用程序后,我遇到了同样的错误,无法安装更多包。

  1. 尝试使用npm cache verifynpm cache clean --force
  2. 如果这不起作用,请尝试使用npm clean-install进行 npm 的全新安装。

这个错误以前发生在我身上,我已经按照这些步骤操作了,我希望它也对你有用。 您需要做的第一件事是卸载 create-react-app,然后再次安装 npm。 您可以使用以下命令卸载 create-react-app:如果您使用的是 NPM:

 npm uninstall -g create-react-app

如果您使用纱线:

yarn global remove create-react-app

要创建新应用程序,您可以使用以下命令:

npx create-react-app@latest your-project-name

您必须注意到 create-react-app 不应像Create-React-app Docs中所记录的那样全局安装。

另请注意,可以肯定地说,始终使用节点的 LTS 版本(此时为 16.13.2)。

它应该可以解决您启动新反应应用程序的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM