这是我第一次使用私人仓库作为另一个项目的依赖项。我认为我做得对,但安装后新项目中的依赖项不可用,并且不在node_modules中。
关注this post我可以看到我正确地将它包含在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)
.......
答案 0 :(得分:6)
如果您指定https,则会查找我认为的登录用户和密码,我不认为它可以自动加载。我会把它简单地列为" user / repo"并确保该机器上有一个ssh密钥,它位于github中,就像https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux等帮助中描述的设置一样,设置的内容使得下拉回购不需要用户交互。
编辑:经过测试,我认为问题是package.json中的name
与您在主项目的依赖项中列出的方式不一致。在我的测试中,这导致了模块的安装,但我收到了无关的消息。