npm commands
Link a package to use it locally
cd ~/path/to/packagenpm linkUnlink a package
cd ~/path/to/packagenpm unlinkRemove from global npm list
npm rm --global <package-name>Check if the package is removed
npm list --globalClear the npx cache
rm -rf ~/.npm/_npxExecute a package without installing it globally
npx <package-name># add @latest to make sure you're using the latest versionnpx <package-name>@latestCommon 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"}// more configs...Happy linking!
react to this snippet