Since version 5.2 of npm (released almost 2 years ago) you also received the command
npx you can run the binaries for your project dependencies (like
npx webpack or
But you can also run any command from any package available on npm!
Here are some of my favorites!
Starts a webserver in the current folder. Great if you want to test something really quick.
npx create-react-app my-app
Use create-react-app without the need to first install it globally. Just run
npx shx touch file # Create a file npx shx mkdir folder # Create a folder
shx command lets you run shell commands, cross-platform! Great if you want to share command snippets that both Mac and Windows users might use.
Sorts the keys in your package.json (if there is a package.json in the current directory).
Test your internet connection
npx typescript index.ts --out index.js
If you want to check the result when TypeScript transforms a .ts file to a .js.
Notice, this is probably for more simple files and mostly if you want to investigate how it works, since you don't use an config file.
npx terser index.js > index.min.js
Gives you an interactive list of available NPM scripts (if you are in a folder with an package.json).
npx puppeteer-cli print https://itiden.se page.pdf npx puppeteer-cli screenshot https://itiden.se page.png
Create an PDF or screenshot from an URL. Notice that Chromium is downloaded when this command i run which makes it quite slow. But might come in handy if you quickly want an PDF or screenshot of an webpage!
And, if you'd like, you can set up your own "card" to display in the terminal. See:
Feel free to comment on more commands that might come in handy!