Instructor: I want to create a new React app, but I don't have it installed globally. We could show this by trying it, and sure enough, the command is not found. We could also verify with NPM that it's not listed globally, with the npm ls create-react-app -- global.
Nope, it's not there. Finally, we could prove that we don't have it installed in a local Node module with npm ls create-react-app. Again, it's not installed. Instead of installing create-react-app globally, we could use NPX instead to temporarily install the package from NPM and execute it.
Let's create a playground React application by typing npx create-react-app playground. At this point, the latest version of the create-react-app is temporarily downloaded. Then it starts to generate the structure of our new React app, and installs all of its necessary dependencies.
Now, we could change directories to our new app and type npm start, and it'll kick up a dev server. Voila, our new web app is running on localhost. Using NPX in this way can be very handy if you'd rather not keep programs installed globally, or if you use them so infrequently that you'd rather just use the latest version whenever you need them.
Also, it could be handy if you just want to play around with some new tools or ideas before committing to them. For example, let's take a look at devpun. We don't have it installed, but we could start using it with npx devpun.
We'll go ahead and pass -t react to filter jokes related to React. Now, we see a joke, even though we don't have devpun installed globally. However, let's continue to play around. Let's pipe the input of devpun to cowsay, with the Vader Cow file.
Now, things are getting interesting. Let's continue to play around a bit, and this time, pipe the output to lolcat.js. Wow, colorful. Using NPX, we're able to play around and experiment with various Node modules without even installing them globally. Pretty cool.