create-react-app 无法识别为内部或外部命令

create-react-app not recognizable as internal or external command

我在 Windows 10 机器上使用 Git Bash 终端。我有以下版本的 nodenpm

$ node -v
v12.16.1

$ npm -v
6.13.4

然而,在 运行 执行命令 $ npx create-react-app my-app 时,出现以下错误

'create-react-app' is not recognized as an internal or external command,
operable program or batch file.

我在 PATH 变量中添加了 create-react-app 位置直到 npm 并使用 echo 命令检查它的存在。

此外,我可以 运行 在 cmd 中使用上述 npx 命令,但不能在 Git Bash 中使用。有什么不一样的我要做吗运行吗?

PATH : /c/Users/SAURABH/AppData/Roaming/npm

不过,我可以通过执行以下操作来 运行 create-react-app:

C:/Users/SAURABH/AppData/Roaming/npm/create-react-app one-hello-world

不确定为什么 npx 不起作用

编辑:我通过将以下内容添加到 PATH

来解决
C:\Users\SAURABH\AppData\Roaming\npm\node_modules

但是上面的路径有create-react-app文件夹,没有批处理文件。它应该指向一些批处理文件吧?

我的 mac 也有同样的问题,开始使用 yarn create react-app my-app 。这个解决方案对我有用。

您应该使用 cmd 或 PowerShell 尝试此命令。这是 GitBash 的一个错误。 我可以用 cmd.

解决这个错误