如何直接从GitHub安装npm包?
尝试从github安装模块会导致: package.json上的enoint错误 使用express轻松复制:如何直接从GitHub安装npm包?,github,npm,npm-install,node-modules,Github,Npm,Npm Install,Node Modules,尝试从github安装模块会导致: package.json上的enoint错误 使用express轻松复制: npm安装https://github.com/visionmedia/express抛出错误 npm install express有效 为什么我不能从github安装 以下是控制台输出: npm http GET https://github.com/visionmedia/express.git npm http 200 https://github.com/visionmedi
npm安装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
npmhttpgethttps://github.com/visionmedia/express.git
npm http 200https://github.com/visionmedia/express.git
npm错误!不是包/home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/tmp.tgz
npm错误!错误:enoint,打开“/home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json”
npm错误!如果需要帮助,您可以在以下位置报告此日志:
npm错误!
npm错误!或通过电子邮件发送至:
npm错误!
npm错误!Linux系统3.8.0-23-generic
npm错误!命令“/usr/bin/node”“/usr/bin/npm”“安装”https://github.com/visionmedia/express.git"
npm错误!cwd/home/guym/dev_env/projects\u GIT/proj/somename
npm错误!节点-v v0.10.10
npm错误!npm-V1.2.25
npm错误!path/home/guym/tmp/npm-32312/1373176518024-0.6586997057311237/package/package.json
npm错误!代码eNONT
npm错误!埃尔诺34
npm错误!
npm错误!其他日志记录详细信息可在以下位置找到:
npm错误/home/guym/dev_env/projects_GIT/proj/somename/npm-debug.log
npm错误!不正常代码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
您也可以执行npm安装visionmedia/express
从Github安装
或
还支持直接从Gist、Bitbucket、Gitlab和许多其他专用格式安装。请查看npm安装程序。如果没有安装git,我们可以尝试
npm install --save https://github.com/Amitesh/gulp-rev-all/tarball/master
彼得·莱昂斯(Peter Lyons)目前的首要答案与最近的NPM版本无关。例如,使用在本回答中受到批评的同一命令现在就可以了
$ npm install https://github.com/visionmedia/express
如果您仍然存在问题,则可能是您使用的任何软件包都有问题。还有npm安装https://github.com/{USER}/{REPO}/tarball/{BRANCH}
使用不同的分支。您也可以这样做
npm i alex-cory/fasthacks
或
基本上:
npm i user_or_org/repo_name
直接安装:
npm install visionmedia/express
或者,您可以将“express”:“github:visionmedia/express”
添加到package.json
文件的依赖项部分,然后运行:
npm install
试试这个命令
npm install github:[Organisation]/[Repository]#[master/BranchName] -g
这个命令对我有效
npm install github:BlessCSS/bless#3.x -g
2016年9月更新
现在可以从github URL安装:
npm install https://github.com/fergiemcdowall/search-index.git
编辑1:您不能对所有模块执行此操作,因为您正在从源代码管理系统读取,该系统可能包含无效/未编译/错误代码。因此,要明确(尽管应该不言而喻):鉴于repo中的代码处于npm可用状态,您现在可以非常高兴地直接从github安装
编辑2:(21-10-2019)我们现在正经历“peak Typescript/React/Babel”,因此JavaScript编译已经变得相当普遍。如果需要考虑编译,请查看prepare
。这就是说,NPM模块不需要编译,明智的做法是假设编译不是默认设置,尤其是对于较旧的节点模块(也可能是非常新的、前沿的“ESNext”-y模块)。现在更新您可以执行的操作:NPM安装git://github.com/foo/bar.git
或者在package.json中:
"dependencies": {
"bar": "git://github.com/foo/bar.git"
}
您可以通过npm install
命令直接安装github repo,如下所示:
npm安装https://github.com/futurechallenger/npm_git_install.git --拯救
注意:在将由npm命令安装的回购协议中:
根据@Dan Dascalescu的评论,也许你的回购协议中必须有一个dist文件夹
你的回购协议中一定要有一个包.json!我忘了加上
这些方法现在已经被很好地介绍了,这里还有很多其他的答案
npm install git+ssh://git@github.com:<githubname>/<githubrepo.git[#<commit-ish>]
npm install git+ssh://git@github.com:<githubname>/<githubrepo.git>[#semver:^x.x]
npm install git+https://git@github.com/<githubname>/<githubrepo.git>
npm install git://github.com/<githubname>/<githubrepo.git>
npm install github:<githubname>/<githubrepo>[#<commit-ish>]
npm安装git+ssh://git@github.com://语法的一般形式是
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
来自npmjs文件:
npm安装:
从托管的git提供程序安装包,并使用
吉特。对于完整的git远程url,将仅尝试该url
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish>
简单:
npm install *GithubUrl*.git --save
例如:
npm install https://github.com/visionmedia/express.git --save
我尝试了npm安装git+https://github.com/visionmedia/express
但这花了太长时间,我不确定这是否行得通
对我有效的是-纱线添加git+https://github.com/visionmedia/express
如果您得到这样的结果:
npm错误!enoint未定义ls remote-h-t
确保您更新到最新的npm,并且您也有权限。您也可以使用git+https://github.com/visionmedia/express.git
使用https而不是ssh。请注意,要安装的存储库必须是npm模块,它必须包含一个package.json
文件,否则会出现以下错误:error:enoint,打开“tmp.tgz unpack/package.json”
。如果我想要一个特定的分支,我现在想到的解决方案是使用…/express.git#commitWorth指定一个commit,这表示您可能需要转义#
以使用shell中的特定分支,即:npm install git+https://github.com/user/repo.git\#分支机构
什么,不指定URL?npm如何知道您使用的是哪种风格的托管服务?@Jake Rayson:这是可能的,因为它只适用于github.com
。它在Windows上对我不起作用-它只是试图从我当前目录的子文件夹中安装。请注意,这在全局安装(即npm i r)上不起作用
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish>
npm install git+ssh://git@github.com:npm/npm.git#v1.0.27
npm install git+ssh://git@github.com:npm/npm#semver:^5.0
npm install git+https://isaacs@github.com/npm/npm.git
npm install git://github.com/npm/npm.git#v1.0.27
GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/npm.git npm install
npm install *GithubUrl*.git --save
npm install https://github.com/visionmedia/express.git --save