github - 如何直接从 GitHub 安装 npm 包

标签 github npm npm-install node-modules

尝试从 GitHub 安装模块会导致此错误:

ENOENT error on package.json.

使用express轻松复制:

npm install https://github.com/visionmedia/express 抛出错误。

npm installexpress 有效。

为什么我无法从 GitHub 安装?

这是控制台输出:

npm http GET https://github.com/visionmedia/express.git
npm http 200 https://github.com/visionmedia/express.git
npm ERR! not a package /home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/tmp.tgz
npm ERR! Error: ENOENT, open '/home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json'
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.8.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "https://github.com/visionmedia/express.git"
npm ERR! cwd /home/guym/dev_env/projects_GIT/proj/somename
npm ERR! node -v v0.10.10
npm ERR! npm -v 1.2.25
npm ERR! path /home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/guym/dev_env/projects_GIT/proj/somename/npm-debug.log
npm ERR! not ok code 0

最佳答案

因为 https://github.com/visionmedia/express 是网页的 URL,而不是 npm 模块。使用此风格:git+{url}.git

git+https://github.com/visionmedia/express.git

如果你需要 SSH,或者这种风格:

git+ssh://git@github.com/visionmedia/express.git

或者如果您需要安装 GitHub Enterprise 存储库:

git+https://<github enterprise url>/<org>/<repo>.git#<branch>

关于github - 如何直接从 GitHub 安装 npm 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17509669/

相关文章:

node.js - 如何使用 NPM v5 安装 Gulp v4?

node.js - 如果全局安装依赖项,NPM/Yarn 会抑制未满足的依赖项警告

node.js - 错误 : network request to https://registry. npmjs.org/yarn 失败,原因 : getaddrinfo ENOTFOUND example. com example.com:8080

github - Jenkins - 当 Github PR 关闭或合并时触发构建

linux - 如何连接github桌面和cpanel

git - 无法将代码 checkin GitHub

javascript - nodejs 应用程序如何在特定时间可靠地执行任务?

docker - 如何使用本地代码更改和我自己的 swagger.json 运行 swagger-ui?

node.js - 使用nvm安装node后无法识别node和npm

npm 安装的版本与 package.json 中指定的版本不同,这怎么可能?如何解决这个问题?