为什么 npm 从私有注册表而不是从registry.npmjs.org 安装包

Sac*_*tal 6 npm npm-install

.nmprc我在项目目录中创建了一个文件:

@mycompany:registry=https://registry.mycompany.com/
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,npm install我看到不以 开头的包依赖项@mycompany也从 开始安装https://registry.mycompany.com/,而不是从 开始安装https://registry.npmjs.org/

这是我在中看到的package-lock.json

"yaml": {
  "version": "1.7.2",
  "resolved": "https://registry.mycompany.com/yaml/-/yaml-1.7.2.tgz",
  "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==",
  "dev": true,
  "requires": {
    "@babel/runtime": "^7.6.3"
   }
Run Code Online (Sandbox Code Playgroud)

小智 5

由于您使用的是 .npmrc 文件,该命令npm install将尝试查找公司注册表中的所有包https://registry.mycompany.com/

如果您想安装所有其他软件包,您需要按如下方式更新 .npmrc 文件。

您当前的 .npmrc 文件:

@mycompany:registry=https://registry.mycompany.com/

更新后的版本

@mycompany:registry=https://registry.mycompany.com/

registry=https://registry.npmjs.org

如果您运行npm install它,它将安装@mycompany您公司注册表中带有 FLag 的所有软件包,并将尝试安装公共 npm 注册表中的所有其他软件包。