Common npm commands to use locally

Published on
2 mins read
––– views

Link a package to use it locally

cd ~/path/to/package
npm link

Unlink a package

cd ~/path/to/package
npm unlink

Remove from global npm list

npm rm --global <package-name>

Check if the package is removed

npm list --global

Clear the npx cache

rm -rf ~/.npm/_npx

Execute a package without installing it globally

npx <package-name>
# add @latest to make sure you're using the latest version
npx <package-name>@latest

Common package.json configs to develop a CLI in NodeJS w Typescript & esbuild

"scripts": {
    "dev": "tsc -w && npm run link",
    "start": "node dist/index.js",
    "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.js",
    "up": "npm run build && npm publish --access public && npm run unlink",
    "link": "npm unlink your-cli && npm i -g && chmod +x ./dist/index.js && npm link your-cli",
    "unlink": "npm rm -g your-cli && npm unlink your-cli"
"bin": {
  "your-cli": "./dist/index.js"

Happy linking!