npx #

Last updated March 11, 2026
javascriptnpm

npx lets you create a command line tool that can be run without already having it installed. To turn your npm module into such a command give it should have a javascript file with a shebang line like this: #!/usr/bin/env node. This can be in your Typescript file and the compiler should make sure it ends up in the final output js file.

Then in your package.json file needs a bin entry pointing to the script like this:

{
  "bin": {
    "amx": "build/cli.js"
  }
}

Now publish your module and run it from another shell with npx -g modulename

Run NPM script in a different dir #

Last updated March 11, 2026
javascriptnpm

You can run an npm script from a different directory by using the --prefix parameter

npm --prefix <path> run <command>

clean NPM cache #

Last updated March 11, 2026
npmjavascript

When you have just released a new package version and npm install in another project says the package doesn’t exist, that could be because it tried to fetch the package before it was really live on npmjs.org. The problem is that it then remembers this forever. So you need to clear out the cache with

npm cache clean --force