简体   繁体   English

使用NPM从专用存储库安装软件包

[英]Installing Package Using NPM from Private Repository

What is the correct syntax in "package.json" so I can install a package from a private npm repository. “ package.json”中的正确语法是什么,因此我可以从私有npm存储库中安装软件包。

My repository is running sinopia at http://localhost:4873 and I have a package called "foo". 我的存储库在http:// localhost:4873上运行sinopia,我有一个名为“ foo”的软件包。 I can upload without issue 我可以上传没有问题

I want something like this in my package.json file: 我的package.json文件中需要这样的内容:

{
  "name": "y",
  ...
  "dependencies": {
      "foo": "http://localhost:4873/"
  },
}

Thanks 谢谢

So it turns out I am not able to do this by way of package.json. 因此,事实证明我无法通过package.json进行此操作。 The most I can do is preregister the server: 我能做的就是预注册服务器:

 npm set registry <server>

Then npm will find my packages as necessary 然后npm会根据需要找到我的软件包

您还可以设置在您的项目,如果你创建一个.npmrc文件registry=http://your_registry在您的项目从你做你的,其中npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM