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?
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.
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/
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/
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
On npm version 3.7.3
npm set registry=http://whatever/
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/
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
npm config set registry=https://registry.npmjs.com/
Will add a line 'registry=https://registry.npmjs.com/' in your .npmrc config file