create-react-app, installation error ("command not found")
node.jsFacebookReactjsNpmnode.js Problem Overview
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
node.js Solutions
Solution 1 - node.js
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
Solution 2 - node.js
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.
Solution 3 - node.js
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
Solution 4 - node.js
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
Solution 5 - node.js
In 2020 Dec 17
Install Nodejs & npm
sudo apt update
sudo apt install nodejs
sudo apt install npm
if you install maybe show you this like errors for Reactjs setup.this helpful for you
npm install -g create-react-app
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-12-17T14_16_02_442Z-debug.log
then When you type after this
create-react-app test-react-app
Show you in terminal zsh: command not found: create-react-app
you fix this error by using this command
sudo npm install -g create-react-app
create-react-app test-react-app
I hope work fine for you also.
Solution 6 - node.js
Answers given above are right but I want to share some things that I also faced and these are basics.
To setup react project
If you want to create a node environment
$ sudo apt-get update
$ sudo apt-get install nodejs
(Sometimes we can also run without sudo
; but sudo means install in system level.)
$ sudo apt-get install nodeenv
$ nodeenv env
$ source /bin/activate
If you want to create new react app then
$ npm install create-react-app
If an error occurs create-react-app: command not found
then install with -g
, it happens because node is installed 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
Solution 7 - node.js
Use npx
instead of npm
.
Check this out-> https://reactjs.org/docs/create-a-new-react-app.html#create-react-app
Solution 8 - node.js
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.
Solution 9 - node.js
This is how I get it fixed.
- Step # 1:- Make sure, Node js and React js is installed globally. You can check Nodejs by
node --version
. If not installed, install and runexport PATH=$HOME/.node_modules_global/bin:$PATH
- Step # 2:- Clean your npm cache by following the command
npm cache clean --force
- run
sudo npx create-react-app your-app-name
And that's it. you're done.
Please note, This solution worked for me for MAC OS
Solution 10 - node.js
I tried all methods listed above and in other sites. They weren't working for me. But for some reason I decided to add the create-react-app directory into my system variables as a last ditch method and to my surprise this actually worked.
Solution 11 - node.js
if you face following this problem:
create-react-app: command not found
solution:
sudo npx create-react-app react_spa
cd react_spa
sudo npm start
I hope its work.
Solution 12 - node.js
If above answers are not working, then try this
- update the npm version (npm install npm@latest -g)
- clear the cache (npm cache clean --force)
- create the react project (npx create-react-app myapp) (while running the 3rd command, make sure that create-react-app is already installed in the pc)