NPM Link multiple Functions / Modules in same Project?

263 views Asked by At

I have a few helper functions I'd like to have available globally in the command line. I have been able to achieve this with npm link, following this tutorial:

{
  "name": "tool1",
  ...
  "bin": "./standalone-functions/tool1.js",
   ...
}

However, I have a few of those in a single project, e.g. standalone-functions/tool1.js, standalone-functions/tool2.js, standalone-functions/tool3.js etc.

But I only have one package.json. So I successfully linked one. But is there a way to also link the others or would I have to have separate projects with separate package.jsons for each?

1

There are 1 answers

0
Roi ben haim On BEST ANSWER

you can add keys to your commands:

"bin": {
    "tool1": "./standalone-functions/tool1.js",
    "tool2": "./standalone-functions/tool2.js",
    "tool3": "./standalone-functions/tool3.js"       
},

and then execute whatever you need.