![](/img/trans.png)
[英]Docker `npm install` with GitHub private repo dependency in TypeScript
[英]Private github repo as dependency is extraneous on npm install
这是我第一次使用私有仓库作为另一个项目的依赖项。 我认为我做得对,但安装后新项目中的依赖项不可用,并且不在node_modules中。
在这篇文章之后,我可以看到我正确地将它包含在package.json中:
"myPackage": "git+https://github.com/myusername/mygitrepository.git"
当我在这个包上运行npm install
时,我看到它没有错误,但是在列表中的这个依赖项之后,它显示为extraneous(git+https://github.com/myusername/mygitrepository.git)
。
即使存在无关紧要的问题,也没有错误,并且依赖项不可用或在node_modules中列出。
更新:repo_A package.json
{
"name": "project-name",
"version": "1.0.0",
"description": "Backend utility functions",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/user/repo.git"
},
"author": "me",
"license": "ISC",
"bugs": {
"url": "https://github.com/user/repo/issues"
},
"homepage": "https://github.com/user/repo#readme",
"dependencies": {
"lodash": "^4.17.4",
"mongodb": "^2.2.25",
"redis": "^2.7.1",
"winston": "^2.3.1"
}
}
更新:repo_B package.json
{
"name": "main-project-name",
"version": "1.0.0",
"description": "",
"repository": {
"type": "git",
"url": "git+https://github.com/user/repo.git"
},
"author": "someone else",
"homepage": "https://github.com/user/repo.git",
"dependencies": {
"async": "2.1.4",
"chai": "^3.5.0",
"langs": "1.1.0",
"lodash": "4.13.1",
"node-stopwatch": "0.0.1",
"request": "2.74.0",
"winston-loggly": "^1.3.1",
"utils": "user/repo_A.git#master"
},
"scripts": {
"test": "mocha"
}
}
更新最新步骤以下是我现在要遵循的步骤,以测试每个可能的解决方案,然后输出:
rm -rf node_modules
npm cache clean
npm install
产量
├─┬ async@2.1.4
│ └── lodash@4.17.4
├─┬ chai@3.5.0
│ ├── assertion-error@1.0.2
│ ├─┬ deep-eql@0.1.3
│ │ └── type-detect@0.1.1
│ └── type-detect@1.0.0
├── util@1.0.0 extraneous (git+ssh://git@github.com/user/repo_A.git#commit-ish)
.......
如果您指定https,则会查找我认为的登录用户和密码,我不认为它可以自动加载。 我会将它简单地列为“user / repo”并确保该机器上有一个ssh密钥,它位于github中,就像帮助中描述的设置一样,例如https://help.github.com/articles/generating-a- new-ssh-key-and-getting-it-to-ssh-agent / #planet-linux并且设置的东西是这样的,以便拉下该repo不需要用户交互。
编辑:经过测试,我认为问题是你在package.json中的name
与你在主项目的依赖项中列出的name
不符。 在我的测试中,这导致了模块的安装,但我收到了无关的消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.