Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash: create-react-app: command not found #1182

Closed
chrisdel101 opened this issue Dec 6, 2016 · 16 comments
Closed

bash: create-react-app: command not found #1182

chrisdel101 opened this issue Dec 6, 2016 · 16 comments

Comments

@chrisdel101
Copy link

chrisdel101 commented Dec 6, 2016

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

@gaearon
Copy link
Contributor

gaearon commented Dec 6, 2016

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.

@gaearon
Copy link
Contributor

gaearon commented Dec 7, 2016

I’ll close because the problem is not specific to CRA—you’d have the same issue with any global Node command.

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

I hope that #1182 (comment) will fix your issue.

@gaearon gaearon closed this as completed Dec 7, 2016
@chrisdel101
Copy link
Author

chrisdel101 commented Dec 7, 2016

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.

@gaearon
Copy link
Contributor

gaearon commented Dec 7, 2016

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?

@chrisdel101
Copy link
Author

chrisdel101 commented Dec 7, 2016

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

@gaearon
Copy link
Contributor

gaearon commented Dec 7, 2016

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?

@chrisdel101
Copy link
Author

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

@gaearon
Copy link
Contributor

gaearon commented Dec 8, 2016

Great, I'm glad you got it working!

@briancbarrow
Copy link

How did you fix your bash profile?

@chrisdel101
Copy link
Author

Why are U having a similar problem?

@briancbarrow
Copy link

Yes I am

@chrisdel101
Copy link
Author

chrisdel101 commented Dec 13, 2016

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/

@briancbarrow
Copy link

@gaearon how would I solve this on Windows?

@chrisdel101
Copy link
Author

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?

@gaearon
Copy link
Contributor

gaearon commented Dec 13, 2016

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.

@briancbarrow
Copy link

briancbarrow commented Dec 13, 2016

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.

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants