Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify registry while doing npm install with git remote url?

I want to be able to clone a git repository using a URL as specified here

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

I am getting an error saying

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

So I should also be able to specify the registry while doing since modules are supposed to be picked up from a internal repository.

Is it possible to specify registry while doing npm install with git remote url?

like image 475
gurvinder372 Avatar asked Feb 25 '16 09:02

gurvinder372


People also ask

What is URL for npm registry?

npm is configured to use the npm public registry at https://registry.npmjs.org by default.

What is the default npm registry?

The default is typically set to the public npm registry at https://registry.npmjs.org/ . For more information about npm configuration files, see the npm config file documentation.


2 Answers

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

npm config set registry <registry url> 

You can also change configs with the help of -- argument. Putting --foo bar on the command line sets the foo configuration parameter to "bar". So you can try something like that:

 npm install http://git.repo.url --registry=https://your.registry.local/ 
like image 118
Alexandr Lazarev Avatar answered Sep 23 '22 05:09

Alexandr Lazarev


Not the best way but If you are using mac or linux even in you can set 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/' 
like image 42
bawa g Avatar answered Sep 21 '22 05:09

bawa g