我有一个模块。它位于私有(private)存储库上。我有它的 git url 以及 https url。但如何将其添加为依赖项。我的 package.json 是
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.4.0",
"jade": "*",
"passport-strategy" : "ssh://git@bitbucket.org/RiteshM/passport-strategy.git"
}
}
它在 npm install 上给我错误
npm http GET https://registry.npmjs.org/passport-strategy
npm http 304 https://registry.npmjs.org/passport-strategy
npm ERR! Error: No compatible version found: passport-strategy@'ssh://git@bitbucket.org/RiteshM/passport-strategy.git'
npm ERR! Valid install targets:
npm ERR! ["1.0.0"]
npm ERR! at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR! at /usr/local/lib/node_modules/npm/lib/cache.js:638:10
npm ERR! at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:133:7
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Linux 3.5.0-40-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/ritesh/projects/passport-topcoder/examples/signin
npm ERR! node -v v0.10.17
npm ERR! npm -v 1.3.8
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ritesh/projects/passport-topcoder/examples/signin/npm-debug.log
npm ERR! not ok code 0
有没有什么方法可以让我们安装模块而无需在 npm 注册表中注册它?请指导。
最佳答案
您的 Git URL 格式不正确。在 npm documentation ,规定 Git URL 必须是以下格式之一:
git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish
所以你的package.json
应该看起来更像这样:
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.4.0",
"jade": "*",
"passport-strategy": "git+ssh://git@bitbucket.org/RiteshM/passport-strategy.git"
}
}
关于node.js - 从 git url 添加模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19286592/