Correct syntax for creating react app project

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on

I will like to know the difference between all this syntax used for creating react project

npx create-react-app my-app
npm create-react-app my-app
npm install -g create-react-app

and which one is the correct one that is supposed to be used.
Thank you

npm install -g create-react-app

Downloads and installs a copy globally (-g), in your user profile and it will be the current version

npm create-react-app my-app

Uses the local (global) copy to create your my-app.

npx create-react-app my-app

Creates the my-app with the latest version directly off the Github site with the current version.

They recommend using

npx create-react-app my-app

I think its because it will always be the most up to date version when you use it. Local versions do not update unless you force them and can be out of date.

If you’ve previously installed create-react-app globally via npm install -g create-react-app , we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

1 Like