尝试从github安装模块导致:
package.json上的ENOENT错误 .
使用快递轻松复制:
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
13 回答
您也可以从Github安装
npm install visionmedia/express
要么
还支持直接从Gist,Bitbucket,Gitlab和许多其他专用格式进行安装 . 看看
npm install
documentation为他们所有人 .因为
https://github.com/visionmedia/express
是网页的URL而不是npm模块 . 使用这种味道:如果你需要SSH,还是这种味道:
直接安装:
或者,您可以将
"express": "github:visionmedia/express"
添加到package.json
文件的"dependencies"
部分,然后运行:这些方法现在在npm's install documentation中得到了很好的介绍,以及其他许多答案 .
However, something notable that has changed recently is npm adding the prepare script to replace the prepublish script. 这解决了一个长期存在的问题,即通过git安装的模块没有运行
prepublish
脚本,因此没有完成将模块发布到npm注册表时发生的构建步骤 . 见https://github.com/npm/npm/issues/3055 .当然,模块作者需要更新他们的package.json以使用新的
prepare
指令来开始工作 .您可以通过
npm install
命令直接安装github仓库,如下所示:npm install https://github.com/futurechallenger/npm_git_install.git --save
NOTE: 在将由npm命令安装的repo中:
根据@Dan Dascalescu的评论,_999_也许你必须在你的回购中有一个dist文件夹 .
如果没有安装git,我们可以试试
语法的一般形式是
这意味着你的情况
来自npmjs文档:
还有
npm install https://github.com/{USER}/{REPO}/tarball/{BRANCH}
使用不同的分支 .Peter Lyons目前的最佳答案与最近的NPM版本无关 . 例如,使用在此答案中受到批评的相同命令现在很好 .
如果您有持续的问题,那么您使用的任何软件包都可能存在问题 .
你也可以这样做
要么
基本上:
2016年9月更新
从vanilla https github URL安装现在似乎工作:
EDIT: 有几个用户评论说您无法为所有模块执行此操作,因为您正在从源控制系统中读取,这可能包含无效/未编译/错误代码 . 所以要清楚(虽然不用说): given that the code in the repo is in an npm-usable state ,你现在可以直接从github安装
试试这个命令
这个命令对我有用 .
现在更新您可以:
npm install git://github.com/foo/bar.git
或者在
package.json
: