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

2019-01-20 23:34发布

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?

8条回答
走好不送
2楼-- · 2019-01-21 00:19

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.

查看更多
做个烂人
3楼-- · 2019-01-21 00:23

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楼-- · 2019-01-21 00:23

On npm version 3.7.3

npm set registry=http://whatever/

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-21 00:30

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

查看更多
闹够了就滚
6楼-- · 2019-01-21 00:34

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
查看更多
该账号已被封号
7楼-- · 2019-01-21 00:36
npm config set registry=https://registry.npmjs.com/

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

查看更多
登录 后发表回答