How to specify registry when installing npm using git remote url?

I want to be able to clone a git repository using the URL provided here

<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish>] 

I get an error

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/XYZ

Thus, I should also be able to specify the registry when you do, because the modules must be selected from the internal repository.

Is it possible to specify a registry when running npm install with git remote URL ?

+5
source share
2 answers

npm gets its configuration settings from the command line, environment variables, and npmrc files. You can try to specify the registry in the npmrc file and the module on the command line. To change the registry, you can use the command:

 npm config set registry <registry url> 

You can also change the configuration with the -- argument. Entering --foo bar on the command line sets the configuration parameter foo " bar ". So you can try something like this:

  npm install http://git.repo.url --registry https://your.registry.local/ 
+13
source

Not the best way, but if you use mac or linux even on windows , you can set an alias for different registries.

 ##############NPM ALIASES###################### alias npm-default='npm config set registry https://registry.npmjs.org' alias npm-sinopia='npm config set registry http://localhost:4873/' 
+2
source

Source: https://habr.com/ru/post/1243827/


All Articles