小编典典

如何直接从 GitHub 安装 npm 包

all

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

package.json 上的 ENOENT 错误。

使用 express 轻松复制:

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

npm install express作品。

为什么我不能从 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

阅读 197

收藏
2022-02-28

共1个答案

小编典典

因为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
2022-02-28