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

wbgh16ku  于 2023-08-04  发布在  Node.js
关注(0)|答案(5)|浏览(154)

这里是Node & React新用户。我正在跟踪React tutorial,但在我的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进程)
  • 在admin中运行CMD
  • 从VS Code Powershell运行命令
  • 在执行命令之前关闭VisualStudio代码
  • 使用npx运行命令
  • 重新启动系统几次
  • 从用户文件夹以及其他驱动器运行命令
  • 运行Typescript版本:第一个月

这对我来说很奇怪,因为在Mac OS X上执行命令没有问题。我也找不到其他有同样问题的人。
无论如何,它总是在“完成abab”包步骤之后停止。
我有一个运行Apache和MySQL服务的XAMPP安装,不知道这是否与它有关。我不这么认为,因为我甚至还没有运行应用程序,加上服务器运行在端口3000反正。

wztqucjr

wztqucjr1#

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

编辑:叮叮叮!是MalwareBytes!“实时保护30天试用版”在更新后重新启动,它正在破坏文件系统。

px9o7tmv

px9o7tmv2#

而不是create-react-app my-app,像npx create-react-app my-app一样运行它。如果错误仍然存在,请运行'npm install -g npm'。然后,再次运行npx create-react-app my-app

n9vozmp4

n9vozmp43#

我刚刚安装了MalWareBytes,也得到了同样的错误。我尝试以管理员身份从CLI运行create-react-app,当它运行时,我阅读了您的解决方案,因此我在安装过程中关闭了MalWareBytes。
它工作了,但我不知道这是因为我作为管理员运行,还是因为我关闭了MalWareBytes。
但是对于任何有此问题的人,您也可以尝试以管理员权限运行命令提示符/powershell。

q7solyqu

q7solyqu4#

尝试从项目目录运行命令...对我很有效我从项目目录的父目录运行命令,例如:reactApp/hellowworld从helloworle目录运行...

pxyaymoc

pxyaymoc5#

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

相关问题