create-react-app 中止,代码为 ENOENT

问题描述 投票:0回答:2

刚刚使用 Udemy 的在线课程开始使用 React。由于某种原因,我的

create-react-app
突然停止工作并显示此日志。

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

npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize
npm ERR! dest C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize' -> 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Vahram\AppData\Roaming\npm-cache\_logs\2021-05-06T21_38_53_463Z-debug.log

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

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting pokedex-exercise/ from C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5
Done.

我在这里查看了类似的问题,并且尝试了一些解决方案。通常的答案是删除

package.json
但我没有看到这一点,因为我正在尝试制作一个新的 React 应用程序。这是我迄今为止尝试过的:

  1. 最初尝试过
    npx create-react-app my_app
  2. 然后尝试运行
    npm install -g create-react-app
    ,然后
    create-react-app my_app
  3. 然后尝试
    npm cache clean --force
    ,然后尝试
    npm rebuild
    ,然后再次执行步骤2。
  4. 然后尝试
    npm init --yes
    生成
    package.json
    文件,然后尝试使用 CRA 再次创建一个新应用程序。
  5. 尝试重启机器

奇怪的是,我注意到我不确定是否与该问题有关: 当我进入任务管理器时,有两个 Node.js 进程正在运行。当我尝试结束一个进程时,它会生成另一个 Node.js 进程...我无法摆脱所有 Node.js 进程。这就是我最初重新启动机器的原因。

如有任何帮助,我们将不胜感激!我不知道如何继续......我什至在考虑格式化我的机器并从头开始一切。不过,我想知道为什么会发生这种情况,以便我以后可以避免这种情况。

javascript reactjs react-native npm create-react-app
2个回答
5
投票

我刚刚使用以下命令解决了这个问题。

npm uninstall -g create-react-app

然后:

npm install -g create-react-app

问候


0
投票

您可以尝试使用重新安装 npx npm i -g npx

© www.soinside.com 2019 - 2024. All rights reserved.