尝试创建react应用时遇到一些问题
PS D:ProjectsTest> npx create-react-app my-app
Creating a new React app in D:ProjectsTestmy-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:UserssemenAppDataRoamingnpm-cache_logs2022-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。谢谢你的帮助!
这个错误以前发生在我身上,我已经遵循了这些步骤,我希望它也适用于您。你需要做的第一件事是卸载create-react应用程序,然后npm再次安装它。您可以使用以下命令卸载create-react应用程序:如果您使用的是NPM:
npm uninstall -g create-react-app
如果您正在使用纱线:
yarn global remove create-react-app
要创建新的应用程序,您可以使用以下命令:
npx create-react-app@latest your-project-name
您必须注意,create-rect应用程序不应全局安装,因为它在create-Rect应用程序文档中有文档记录。
此外,请注意,可以肯定地说,始终使用node的LTS版本(此时为16.13.2(。
它应该可以通过启动一个新的react应用程序来解决您的问题。
我在创建React应用程序后遇到了同样的错误,无法再安装任何软件包。
- 尝试使用
npm cache verify
或npm cache clean --force
清除缓存 - 如果不起作用,请尝试使用:
npm clean-install
进行npm的干净安装