Home > Blockchain >  How to properly execute an executable supplied by a package that I wrote (or cloned), without also c
How to properly execute an executable supplied by a package that I wrote (or cloned), without also c

Time:01-27

I created a package named env-subset that supplies an executable via the bin key in package.json:

  "bin": {
    "env-subset": "./index.js"
  },

Is there an official blessed way to make this executable actually materialize somewhere so that I can execute it, without doing any of the following:

  • explicitly creating another package that pulls my package as a dependency
  • installing my package globally, i.e. implicitly pulling it as a dependency of the implicit global package
  • writing a wrapper script that executes node path/to/my/env-subset/index.js and low key hopes it won't fail in a thousand places?

CodePudding user response:

Install your package as a dependency of itself:

pnpm add -D env-subset@link:

Now you can run:

pnpm env-subset

Or:

./node_modules/.bin/env-subset
  • Related