npx create-react-app 似乎不起作用

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

我正在尝试通过运行以下命令来创建 React 应用程序样板

npx create-react-app my-app

我收到以下错误

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\dejean\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\dejean\AppData\Roaming\npm'   
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\dejean\AppData\Local\npm-cache\_logs\2023-06-27T18_53_22_682Z-debug-0.log

我使用节点 18.16.1 和 npm 9.5.1

node.js reactjs npm create-react-app npx
2个回答
0
投票

运行

npm install -g npm
升级节点包管理器


-4
投票

您遇到的错误似乎与 npm 无法找到特定文件或目录有关。您运行的命令似乎正在尝试访问目录“C:\Users\dejean\AppData\Roaming pm”,但无法找到它。

您可以尝试执行以下几个步骤来解决此问题:

确保您的系统上安装了 Node.js 和 npm。您可以通过在命令提示符或终端中运行以下命令来验证这一点:

node -v
npm -v

如果安装了 Node.js 和 npm,请尝试运行以下命令将 npm 更新到最新版本:

npm install -g npm@latest

如果问题仍然存在,则可能是您的 npm 配置或安装存在问题。您可以尝试通过运行以下命令来重置 npm 配置:

npm config set prefix ""

重置 npm 配置后,尝试再次运行 create-react-app 命令:

npx create-react-app my-app
© www.soinside.com 2019 - 2024. All rights reserved.