create-react-app, installation error ("command not found")

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.

Next instruction:

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!

Thanks in advance.

Note: I'm using Node v6.3.1, and npm v3.10.3

Answers


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.

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.

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

You are able to apply the following solution:

$ npm config set prefix /usr/local
$ sudo npm install -g create-react-app
$ create-react-app my-app

The environment variables are not set properly. When you run the create-react-app it shows you a path along with the error. Copy that path and add it in the environment variable.

Alternatively you can use the command:

npx create-react-app <app_name>.

This will do the work for you.


Try this. It worked or me. I found this in the React documentation. "Npx" is not a typo. It's a package runner tool that comes with npm 5.2+.

npx create-react-app my-app


I am having the same problem and this solution did not work for me. I have:

export PATH=$HOME/.node_modules_global/bin:$PATH

in .bash_profile

Currently echo $PATH shows:

/Users/username/.node_modules_global/bin:/Users/username/.rvm/gems/ruby-2.1.6/bin:/Users/username/.rvm/gems/ruby-2.1.6@global/bin:/Users/username/.rvm/rubies/ruby-2.1.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/username/.rvm/bin

If I go to Home I can see .npm and .npm-global. There is a an alias to create-react-app at .npm-global/bin/ and a folder at

.npm-global/lib/node_modules/create-react-app


Answers given above are wright but wanna share somethings that i also face and these are basics ================To setup react project ============================

If wanna create a node environment

$sudo apt-get update
$sudo apt-get install nodejs

(sometime we can also use but sudo menas install in system level $apt-get nodeenv)

$sudo apt-get nodeenv

$nodeenv env
$ source /bin/activate

If wanna react new react app then

$ npm install create-react-app
if error occurs create-react-app: command not found then install with -g, its happens because node is install globally and it is not

getting the node in local

$npm install -g create-react-app

$create-react-app app_name
$cd app_name
app_name$ npm start

I hope you already installed Node package manager(npm). now run npm install -g create-react-app, if everything fine then you can use create-ract-app command. if you are getting any permission error just sudo npm install -g create-react-app.

I hope it will work. Happy Hacking.


Need Your Help

In Go, does a break statement break from a switch/select?

select switch-statement go break

I know that switch/select statements break automatically after every case. I am wondering, in the following code:

Task.WhenAny and Unobserved Exceptions

c# .net task-parallel-library .net-4.5 async-await

Let's say I have three tasks, a, b, and c. All three are guaranteed to throw an exception at a random time between 1 and 5 seconds. I then write the following code: