我正在尝试使用 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
我在 google 上搜索了该错误,并偶然发现了一些答案,这些答案建议将 npm 路径添加到系统变量或将系统 32 路径添加到系统变量。
我的用户变量
C:\Program Files\nodejs\
C:\Program Files\nodejs\node_modules\npm
我的系统变量
%SystemRoot%\system32\cmd.exe
C:\Program Files\nodejs
我对 Node js 不太熟悉,并且很难理解互联网上提供的答案。
有人可以用适当的答案解释一下情况吗?
最佳答案
尝试以下命令来启动并运行 npx:
- npm cache clean --force
- npm init
- npm install create-react-app
- npx create-react-app myapp
关于node.js - NPX-CRA : creating react app, 使用 npx 会引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60457687/