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 fornpm
. The correct command for changing registry isnpm 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.We can also run npm install with
registry
options for multiple custom registry URLs.On npm version 3.7.3
npm set registry=http://whatever/
On version 4.4.1, you can use:
Where @myco is your package scope. You can install package in this way:
ref: https://docs.npmjs.com/misc/scope
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 asWill add a line 'registry=https://registry.npmjs.com/' in your .npmrc config file