使用 create-react-app 时出错 - ENOENT

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

这里有新的 Node 和 React 用户。我正在遵循 React 教程,但在我的 Windows 10 计算机上遇到问题:

C:\Users\Wout>create-react-app my-app

Creating a new React app in C:\Users\Wout\my-app.

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

npm ERR! path C:\Users\Wout\my-app\node_modules\abab
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Wout\my-app\node_modules\abab' -> 'C:\Users\Wout\my-app\node_modules\.abab.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\Wout\AppData\Roaming\npm-cache\_logs\2018-03-14T15_21_11_867Z-debug.log

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

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting my-app / from C:\Users\Wout
Done.

到目前为止我尝试过的事情:

  • 重新安装 Node.js(v8.10.0,npm 5.6.0)
  • 禁用 Adobe Creative Cloud 同步及相关进程(这些进程会生成 node.exe 进程)
  • 在管理员中运行CMD
  • 从 VS Code Powershell 运行命令
  • 执行命令之前关闭 Visual Studio Code
  • 使用 npx 运行命令
  • 重启系统数次
  • 从用户文件夹以及其他驱动器运行命令
  • 运行 Typescript 版本:
    create-react-app my-app --scripts-version=react-scripts-ts

这对我来说很奇怪,因为在 Mac OS X 上该命令执行没有问题。我似乎也找不到其他有同样问题的人。

不管怎样,它总是在“完成 abab”包步骤之后停止。

我安装了运行 Apache 和 MySQL 服务的 XAMPP,不知道这是否与之有关。我不这么认为,因为我什至还没有运行该应用程序,而且服务器无论如何都在端口 3000 上运行。

node.js reactjs npm create-react-app
6个回答
6
投票

我最终通过关闭尽可能多的额外进程解决了这个问题。将尝试找出哪个进程干扰了该命令。

编辑:叮叮叮!这是 MalwareBytes! “实时保护 30 天试用版”在更新后重新启动,并且与文件系统发生冲突。


6
投票

而不是

create-react-app my-app
,像
npx create-react-app my-app
那样运行它。如果错误仍然存在,请运行“npm install -g npm”。然后,再次运行
npx create-react-app my-app


0
投票

我也刚刚安装了 MalWareBytes,也遇到了同样的错误。我尝试以管理员身份从 CLI 运行 create-react-app,在运行时我阅读了您的解决方案,因此我在安装过程中关闭了 MalWareBytes。

它有效,但我不知道这是因为我以管理员身份运行,还是因为我关闭了 MalWareBytes。

但是对于遇到此问题的任何人,您也可以尝试使用管理员权限运行命令提示符/powershell。


0
投票

尝试从项目目录运行命令... 为我工作。 我从项目目录的父目录运行命令,例如: 反应应用程序/helloworld 改为从 hellowole 目录运行...


0
投票

如果您刚刚安装了 create-react-app 命令,请尝试从新终端运行该命令。 (重新打开另一个选项卡)。


0
投票

尝试运行>“npm 基金” 然后尝试重新运行 > 'npm create-react-app my-app'

这对我有用。

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