“npm config set registry https://registry.npmjs.or

2019-01-20 23:45发布

问题:

I create a.bat on windows 7, the content of a.bat is:

@echo off
npm config set registry https://registry.npmjs.org/

and then run a.bat, but not working, I find the word "set" is special keyword for npm and bat, is there any methods to resolve this question?

回答1:

You shouldn't change the npm registry using .bat files. Instead try to use modify the .npmrc file which is the configuration for npm. The correct command for changing registry is

npm config set registry <registry url>

you can find more information with npm help config command, also check for privileges when and if you are running .bat files this way.



回答2:

You can change using the .bat make sure you run the call command prior, hopefully this helps anyone in future making similar .bat commands

call npm config set registry https://registry.npmjs.org/


回答3:

We can also run npm install with registry options for multiple custom registry URLs.

npm install --registry=https://registry.npmjs.org/ 
npm install --registry=https://custom.npm.registry.com/ 


回答4:

On version 4.4.1, you can use:

npm config set @myco:registry http://reg.example.com

Where @myco is your package scope. You can install package in this way:

npm install @myco/my-package

ref: https://docs.npmjs.com/misc/scope



回答5:

On npm version 3.7.3

npm set registry=http://whatever/



回答6:

Probably I am too late to answer. But if anybody need it, following works fine, as I have used it a lot of times.

npm config set registry=https://registry.npmjs.com/


回答7:

By executing your .bat you are setting config for only that session not globally. When you open and another cmd prompt and run npm install that config will not set for this session so modify your .bat file as

@echo off
npm config set registry https://registry.npmjs.org/
@cmd.exe /K


回答8:

npm config set registry=https://registry.npmjs.com/

Will add a line 'registry=https://registry.npmjs.com/' in your .npmrc config file