“npm config set registry https://registry.npmjs.org/” is not working in windows bat file

前端 未结 10 1497
自闭症患者
自闭症患者 2020-12-12 10:08

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

10条回答
  •  无人及你
    2020-12-12 10:39

    You might not be able to change npm registry using .bat file as Gntem pointed out. But I understand that you need the ability to automate changing registries. You can do so by having your .npmrc configs in separate files (say npmrc_jfrog & npmrc_default) and have your .bat files do the copying task.

    For example (in Windows): Your default_registry.bat will have

    xcopy /y npmrc_default .npmrc
    

    and your jfrog_registry.bat will have

    xcopy /y npmrc_jfrog .npmrc
    

    Note: /y suppresses prompting to confirm that you want to overwrite an existing destination file.

    This will make sure that all the config properties (registry, proxy, apiKeys, etc.) get copied over to .npmrc.

    You can read more about xcopy here.

提交回复
热议问题