switching npm registry based on directory

前端 未结 3 451
余生分开走
余生分开走 2021-02-07 03:21

I have recently started developing for node. The company that I work for has an internal npm registry. I want to know how to use different registry settings depending upon where

相关标签:
3条回答
  • 2021-02-07 03:59

    There are two distinct use cases for using your private npm registry:

    1. Installing: use the --reg or --registry flag:

      npm install mypackage --reg http://myreg.npmjitsu.com
      
    2. Publishing: you can also use --reg or --registry, but I would highly recommend that you use the publishConfig setting in your package.json file (See: the npm documentation)

      {
        "publishConfig": {
          "registry": "http://myreg.npmjitsu.com"
        }
      }
      

      This prevents developers from accidentally publishing private modules to the public registry by forgetting the --registry flag

    So add publishConfig to all of the package.json for your Company use --registry when installing from their private npm.

    0 讨论(0)
  • 2021-02-07 04:02

    https://github.com/npm/npm/issues/4751

    npm recently added support for per-package .npmrc files, should do what you want.

    0 讨论(0)
  • 2021-02-07 04:10

    Registry should only be needed when you're installing packages. You can use this when you wish to install from the private registry.

    npm install packagename --registry https://myregistryurl
    

    This may work too..

    npm install https://myregistryurl/packagename
    

    and just install the normal way when you're using the public registry.

    0 讨论(0)
提交回复
热议问题