Tuesday, September 4, 2018

Npm multiple registries for a single scope, defined in multiple files

Leave a Comment

Currently, in my project .npmrc I have the following and that works fine

//private tfs server @scope:registry=http://server:8080/tfs/ //locally hosted server @scope:registry=http://localhost:4873/ always-auth=true 

I wanted to move @scope:registry=http://localhost:4873/ out of the file as I am the only one running a local npm repository and I don't want to accidentally check it in.

It looks like npm overwrites registry entries, which makes sense if they are key-value pairs. However this puts me in an awkward spot.

To summarise: I would like to have multiple registries for a single scope, defined in different files.

1 Answers

Answers 1

You should use something like Node config to do this kind of hierarchical configuration.

Node-config organizes hierarchical configurations for your app deployments.

It lets you define a set of default parameters, and extend them for different deployment environments (development, qa, staging, production, etc.).

This way you can have a default.json with your dev configs, and create a production.json with your prod settings.

Then start your app server:

$ export NODE_ENV=production $ node my-app.js 

Hope it helps!

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment