NPX-CRA:创建react应用程序,使用 npx 会引发错误

IT技术 node.js reactjs
2021-05-21 06:27:36

我正在尝试使用 npx 命令创建一个 React 应用程序,如下所示

npx create-react-app my-app

但这给了我一个错误说

'CALL "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,
operable program or batch file.
spawn C:\Windows\system32\cmd.exe;C:\xampp\php ENOENT

我在谷歌上搜索了错误并偶然发现了一些建议将 npm 路径添加到系统变量或将系统 32 路径添加到系统变量的答案。

我的用户变量

C:\Program Files\nodejs\
C:\Program Files\nodejs\node_modules\npm

我的系统变量

%SystemRoot%\system32\cmd.exe
C:\Program Files\nodejs

我对 node js 不太熟悉,并且难以理解互联网上可用的答案。

任何人都可以用适当的答案解释这种情况吗?

1个回答

尝试以下命令来启动并运行 npx:

- npm cache clean --force
- npm init
- npm install create-react-app
- npx create-react-app myapp