create-react-app上的“'npm'不被识别为内部或外部命令”

时间:2019-04-07 00:46:11

标签: javascript node.js reactjs npm

为什么npm无法识别?

我正在尝试学习反应并开始使用它。我已经安装了节点,并且包create-react-app。

如果我在命令行中输入npm -vcreate-react-app -V,它将返回我拥有的当前版本。这是我的问题的第一步。

第二步将检查环境路径。

我的路径中有C:\Users\hunte\AppData\Roaming\npm,甚至没有管理员的身份就以管理员身份运行bash命令行。

我认为第三步将重新启动计算机。 (显然它没有用)

我如何安装并尝试加强反应就像这样...

npm install -g create-react-app

create-react-app my-app

然后返回'npm' is not recognized as an internal or external command.

我迷路了,因为我真的很想学习react.js,因此寻求一些帮助来解决这个问题。

感谢所有花时间阅读我的问题的人。

这是我的cmd

$ create-react-app test

Creating a new React app in C:\Users\hunte\desktop\test\test.

'npm' is not recognized as an internal or external command,
operable program or batch file.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

'npm' is not recognized as an internal or external command,
operable program or batch file.

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts@0.9.x has failed.

Deleting generated file... package.json
Deleting test/ from C:\Users\hunte\desktop\test
Done.

2 个答案:

答案 0 :(得分:1)

我知道了!

对于遇到类似问题的每个人,我要做的就是更改CMD。

我更喜欢使用Git Bash CMD;但是,我想它在系统路径/环境下不能很好地工作。

我为解决此问题所做的一切都是以管理员身份运行 默认cmd 并再次尝试。这次它起作用了,我成功创建了react包。

答案 1 :(得分:0)

使用默认的命令提示符对我有用。我之前在 Hyper 工作。