Create-react-app: bash: create-react-app: command not found

Created on 6 Dec 2016  路  16Comments  路  Source: facebook/create-react-app

Can you reproduce the problem with latest npm?

I have had alot of problems getting npm installed overall and spent around 6 hours getting to the point where I think it is installed now. I run npm -v and get a number, likewise for node.

All packages were working and I had to update to use your package. I could not, so deleted with all packages and tried to reinstall new version. After regular way failed I was able to get it installed, node and Npm, with homebrew after I made a few permissions changes (with difficulty).

Description

I've tried several different ways of getting this to work but I always get the error above.
This is what I got when I installed the package-
`sudo npm install -g create-react-app (I also tried non-sudo)

/Users/name/.npm-packages/bin/create-react-app -> /Users/name/.npm-packages/lib/node_modules/create-react-app/index.js
/Users/name/.npm-packages/lib`

I looked in the the node_modules and the package is there. I've added this-

export PATH="./node_modules/.bin:$PATH" and also I tried it with the full path. It did not work.

I am not great with bash_profile, permissions, etc. so I can't figure out what I need to do. If this is a node problem I apologize but I still need help regardless.

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts - npm ERR! code 1
    -bash: /Users/name/Desktop/code_work/react_lynda/bulletin_board: is a directory
  2. node -v: - 7.2.0
  3. npm -v: -3.10.9

Then, specify:

  1. Operating system: IOS
  2. Browser and version: Chrome

#

Most helpful comment

The problem was not with CRA, but with node/npm.

Installing Node from scratch, non-homebrew, I put these in my bash_profile. And it worked.

export PATH="/usr/local/bin:$PATH"

export PATH=$PATH:/Users/my_name/.npm-packages/bin/

All 16 comments

Hi! The log you posted says it got installed to /Users/name/.npm-packages/bin/. Could you add that directory to PATH? I'm not sure where ./node_modules/.bin is coming from and I don't think you need it there.

I鈥檒l close because the problem is not specific to CRA鈥攜ou鈥檇 have the same issue with any global Node command.

That you need sudo is a bad sign but unfortunately I can鈥檛 really help with debugging this. I recommend checking Node.js and nvm documentation for instructions on installing Node.

I hope that https://github.com/facebookincubator/create-react-app/issues/1182#issuecomment-265298644 will fix your issue.

Was the idea to paste your code overtop of the current entry, or add it in addition to? Replacing it with the snippet above made no change. I found your package as part of a tutorial and the instructor told me to use sudo.

I know this is undoubedley a pain for you but I really have trouble with the Node docs as a beginner and can't navigate them.

Yeah I understand. I'm not good with this either. When I was installing Node for the first time I think I used brew, and it just worked.

Was the idea to paste your code overtop of the current entry, or add it in addition to?

Likely in addition to. What does echo $PATH print in your terminal?

So I unistalled node and npm again. Reinstalled non-homebrew. Put
export PATH="/usr/local/bin:$PATH"
as per Node installation instructions. Make sure that /usr/local/bin is in your $PATH.

Tried to install react-app. Had a permission error, basic one.

npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access 

Fixed the permissions error and the package installed properly. Found the package in appropriate folder.

Still:
npm install -g create-react-app\ bash: create-react-app: command not found
My path is a long list since I have other things in my bash_profile. I see the /usr/local/bin there though. It's in quotes. I think I need to take a bash tutorial :0

You need to figure out where create-react-app got installed. On my machine it's in /usr/local/bin/create-react-app. Do you have this file?

This has been solved. It was a problem in bash profile.

Great, I'm glad you got it working!

How did you fix your bash profile?

Why are U having a similar problem?

Yes I am

The problem was not with CRA, but with node/npm.

Installing Node from scratch, non-homebrew, I put these in my bash_profile. And it worked.

export PATH="/usr/local/bin:$PATH"

export PATH=$PATH:/Users/my_name/.npm-packages/bin/

@gaearon how would I solve this on Windows?

No idea. Never used Windows. I'd only be throwing out random guesses.

Try reinstalling node. If it installs properly this should clear up the CLI issue.
If not U'll have to debug your node install. That was the root of my problem.

Is npm/node working properly?

When I was testing Windows support I followed Node installation instructions and then launched "Node.js command prompt" that appeared in the Start menu. This worked for me, and I could launch create-react-app from there.

For anyone else with this problem on Windows, I found the following instructions that worked for me: (from this link http://stackoverflow.com/questions/19874582/change-default-global-installation-directory-for-node-js-modules-in-windows)

"to resolve this, change global install directory to C:\Users\{username}\AppData\Roaming\npm:
in C:\Users\{username}\, create .npmrc file with contents:
prefix = "C:\\Users\\{username}\\AppData\\Roaming\\npm"  

After this I reinstalled create-react-app and I got it to work.

Was this page helpful?
0 / 5 - 0 ratings