在 Windows 上创建 React 应用程序时遇到 ENOENT 错误:无法找到目录

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

在尝试使用 npx create-react-app 创建新的 React 应用程序时,我遇到了一个持续存在的问题。在我的项目目录中。尽管执行了多个故障排除步骤,我仍然收到与 npm 路径相关的 ENOENT 错误。

当我尝试使用 GitBash 在我的项目目录中使用 ( npx create-react-app .) 创建新的 React 应用程序时,遇到了一个持续存在的问题。尽管执行了几个故障排除步骤:

  1. 安装了 Node.js 最新版本,并确保包含 npm。
  2. 检查了 npm 配置:我运行了( npm config get prefix ),它返回了适当的响应。
  3. 我将 npm 路径添加到 Windows 系统环境变量中,确保它包含正确的目录。
  4. 我尝试使用( npm cache clean --force )清除 npm 缓存,但问题仍然存在。
  5. 还尝试以管理员身份运行 GitBash,但也失败了。
  6. 我在适当的位置手动创建了 npm 目录,但没有解决问题。
  7. 我没有重新安装 npm,因为我今天刚刚安装了它。
  8. 还验证了我拥有 npm 目录的权限。

这是以下错误消息:

npm error code ENOENT
npm error syscall lstat
npm error path C:\Users\<username>\AppData\Roaming\npm
npm error errno -4058
npm error enoent ENOENT: no such file or directory, lstat 'C:\Users\<username>\AppData\Roaming\npm'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
node.js windows npm create-react-app
1个回答
0
投票

似乎您还没有全局安装

npm
。尝试使用

npm install npm -g

从你的目录中,之后它应该可以工作。

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