When it's a package that I'll use infrequently, such as create-react-app, I'll use npx
. However, there are some utility packages I use again and again. To install globally either npm i -g <package-name>
or even better, add them to ~/.nvm/default_packages
.
rimraf
npm i -g rimraf
rimraf [path]
It's rm -rf
but works whereever you have node - macOS, Windows, WSL, node.
http-server
npm i -g http-server
http-server [path]
Quickly serve a directory through localhost:8080 with zero-config.
netlify-cli
npm i -g netlify-cli
netlify deploy
Deploy a site to Netlify from the command line. I'll use this to deploy temporary site when I need to demo work in progress.
nodemon
npm i -g nodemon
nodemon app.js
This will run your code in Node and automatically restart if it detects any files changes in the directory. Great to have installed globally for quick scripts.
sort-package-json
npm i -g sort-package-json
sort-package-json
Predictably, this sorts the package.json of your current directory. Tidy package.json, tidy mind.
fkill-cli
npm i -g fkill-cli
fkill node --force
Cross-platform process killer. Useful when you have node running in the background and you've closed the terminal window that started it.
concurrently
npm i -g concurrently
concurrently "command1 arg" "command2 arg"
Run multiple commands concurrently.
List globally installed packages
Run this command to see what you have installed globally.
npm ls -g --depth=0