I have a few npm package listed in package.json file , some are public and some are private. I want to install both types of packages in single command by using npm install
.
If npm registry set on global, private package shows 404
, so how to achieve this by single command.I want Both types of package install on node_modules.
npm --usercofig=./.npmrccorp i
: This will install the modules as mentioned inpackage.json
while considering the configuration file supplied by the--userconfig
argument. The lasti
andinstall
are interchangeable. This can be rewritten asnpm --usercofig=./.npmrccorp
install alsoTo install both private and public packages with single
npm --usercofig=./.npmrccorp i
command you need to maintain both thedependencies
inpackage.json
dependencies node and then there should be a .npmrccorp file containing your authentication token as follows:package.json:
.npmrccorp
After did all experiment, i up all my private package to server as a scoped package. like as
@private/jsonwrite
,@private
is my scoped name. then i write below config in.npmrc
then just run
npm install
, it works both on remote and global package. Which is scoped package download from.npmrc
given link and rest of others from global npm.The faster solution is what @hugomarisco suggested in the comment section. I'll assume your private package is in any registry (A) and the remainings are fetched from npmjs (B).
To make it more clear, you can use verdaccio and set up your multiples registries as uplinks as is visualized here.
Your uplink configuration might look like this,
and then just define the package access to each remote by patterns
In such way, you can access your private packages safely while verdaccio fetch for you those belong any public registry as npmjs.
In your terminal just do
and you are set. I hope that helps.