create-react-app not currently working

北城以北 提交于 2019-12-25 04:13:49

问题


I've ran npm install create-react-app -g and then

create-react-app hello-world

returns

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

I understand that my $PATH is currently messed up. Here's what is returned from echo $PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

I really don't know what to set this as, as I'm currently very new to the terminal. Any help would be greatly appreciated. Thank you!


回答1:


Just export path to .bashrc and then call it from .profile file all in $Home directory then restart. e.g: .bashrc file:

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

.profile file:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
       . "$HOME/.bashrc"
    fi
fi

 # set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi



回答2:


So I have been having this problem recently and it was because I was just typing create-react-app [app-name].

If anyone runs into this problem again instead type npx create-react-app [app-name], npm init react-app [app-name] or yarn create react-app [app-name].

https://facebook.github.io/create-react-app/docs/getting-started

Hope that helps someone!




回答3:


Im not 100% sure on the answer to your question. However; if you are simply trying to setup a react environment, I suggest referring to a Youtube tutorial on React. Create a folder on your desired directory then go to specific directory using Command prompt, or gitBash, or Cygwin and using NodeJs you can install everything you need to get started.Follow the first 10 min to set it up and then you're good to go. Good luck

https://www.youtube.com/watch?v=IR6smI_YJDE&t=278s&list=PLbeWHDJFd79RXvAeGaDXMmxL_tkb3MvdH&index=1




回答4:


Add npm-packages to path in you .bash_profile

echo 'export PATH="$HOME/.npm-packages/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile



回答5:


I had same issue, although long term fix to get your $PATH fixed, but I can give you "quick and dirty" way to get your create-react-app started.

This is the output I got after install create-react-app and I used the path to use the command

BatMan-MacBook-Pro:coursera-react batman$ sudo npm install -g create-react-app

/Users/batman/.npm-packages/bin/create-react-app -> /Users/batman/.npm-packages/lib/node_modules/create-react-app/index.js
+ create-react-app@2.1.1
updated 1 package in 2.594s

And I used the path from above to get it going and it worked.

BatMan-MacBook-Pro:coursera-react batman$ /Users/batman/.npm-packages/bin/create-react-app BatManCafe


来源:https://stackoverflow.com/questions/41295180/create-react-app-not-currently-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!