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

后端 未结 8 1375
遇见更好的自我
遇见更好的自我 2020-12-08 07:09

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.

相关标签:
8条回答
  • 2020-12-08 07:33

    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.

    0 讨论(0)
  • 2020-12-08 07:36

    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.

    0 讨论(0)
  • 2020-12-08 07:37

    Use npx instead of npm.

    Check this out-> https://reactjs.org/docs/create-a-new-react-app.html#create-react-app

    0 讨论(0)
  • 2020-12-08 07:42

    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.

    0 讨论(0)
  • 2020-12-08 07:43

    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
    
    0 讨论(0)
  • 2020-12-08 07:51

    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
    
    0 讨论(0)
提交回复
热议问题