创建反应应用程序,安装错误(“未找到命令”) [英] create-react-app, installation error ("command not found")
问题描述
我已经按照facebook指示页面上的指示安装了创建反应应用程序( https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html ):
I have installed create-react-app exactly as instructed on the facebook instruction page (https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html):
首先,安装全球包:
First, install the global package:
npm install -g create-react-app
我这样做了。它似乎工作正常 - 文件安装到
I did this. It appeared to work fine - the file was installed to
users/*name*/.node_modules_global/lib/node_modules/create-react-app
我不太确定为什么全局安装将其带到这个路径,但是在那里
I'm not really sure why global install takes it to this path, but there you have it.
下一条说明:
现在可以使用它来创建一个新的应用程序:
Now you can use it to create a new app:
create-react-app hello-world
不能简单,对吧?但是终端在我身上吐了出来:
Couldn't be simpler, right? But Terminal spits out this at me:
-bash: create-react-app: command not found
这可能是一件非常简单的事情,但我不知道在哪里看。如果有人可以帮助我真的很感激!
It's probably something very simple I'm missing but I don't really know where to look. If anyone can help I'd really appreciate it!
提前感谢
注意:我正在使用Node v6.3.1和npm v3.10.3
推荐答案
您的节点设置看起来不正确。这不是创建React应用程序的问题 - 似乎您无法运行任何全局Node命令。
Your Node setup looks incorrect. It's not an issue with Create React App—it seems like you can't run any global Node commands.
它看起来像〜/ .node_modules_global / bin
不在您的 PATH
环境变量中,因此无法执行全局命令。这就是Bash的工作原理 - 它不能猜测命令在哪里,你需要告诉它。我会假设Node安装应该默认这样做,但这取决于您如何安装Node。
It looks like ~/.node_modules_global/bin
is not in your PATH
environment variable so it can't execute global commands. That's just how Bash works—it can't guess where the command lies, you need to tell it. I would assume Node installation should do this by default but it depends on how you installed Node.
所以确保该目录位于您的 PATH
,然后重试。如果您使用Bash,请将其添加到您的 .profile
中,然后重新启动终端:
So make sure that directory is in your PATH
and try again. If you use Bash, add this to your .profile
and then restart the Terminal:
export PATH=$HOME/.node_modules_global/bin:$PATH
这篇关于创建反应应用程序,安装错误(“未找到命令”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!