Node.js 从git url添加模块

Node.js 从git url添加模块,node.js,npm,Node.js,Npm,我有一个模块。它位于私有repo上。我有它的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": "*",

我有一个模块。它位于私有repo上。我有它的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安装错误

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
npmhttpgethttps://registry.npmjs.org/passport-strategy
npm http 304https://registry.npmjs.org/passport-strategy
npm错误!错误:找不到兼容版本:passport strategy@'ssh://git@org/RiteshM/passport strategy.git'
npm错误!有效的安装目标:
npm错误!["1.0.0"]
npm错误!在installTargetsError(/usr/local/lib/node_modules/npm/lib/cache.js:719:10)
npm错误!在/usr/local/lib/node_modules/npm/lib/cache.js:638:10
npm错误!保存时(/usr/local/lib/node_modules/npm/node_modules/npm registry client/lib/get.js:142:7)
npm错误!at/usr/local/lib/node_modules/npm/node_modules/destanced fs/polyfills.js:133:7
npm错误!在Object.oncomplete(fs.js:107:15)
npm错误!如果需要帮助,您可以在以下位置报告此日志:
npm错误!
npm错误!或通过电子邮件发送至:
npm错误!
npm错误!Linux系统3.5.0-40-generic
npm错误!命令“/usr/local/bin/node”“/usr/local/bin/npm”“安装”
npm错误!cwd/home/ritesh/projects/passport topcoder/examples/signin
npm错误!节点-v v0.10.17
npm错误!npm-V1.3.8
npm错误!
npm错误!其他日志记录详细信息可在以下位置找到:
npm错误/home/ritesh/projects/passport-topcoder/examples/signin/npm-debug.log
npm错误!不正常代码0

我们是否有任何方法可以安装模块而无需在npm注册表上注册?请提供指导。

您的Git URL格式不正确。在中,声明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"
  }
}