GitHub에서 직접 npm 패키지를 설치하는 방법은 무엇입니까?
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
https://github.com/visionmedia/express
npm 모듈이 아닌 웹 페이지의 URL 이기 때문 입니다. 이 맛을 사용하십시오 :
git+https://git@github.com/visionmedia/express.git
또는 SSH가 필요한 경우이 맛 :
git+ssh://git@github.com/visionmedia/express.git
npm install visionmedia/express
Github에서 설치할 수도 있습니다.
또는
npm install visionmedia/express#branch
Gist, Bitbucket, Gitlab 및 기타 여러 특수 형식에서 직접 설치하기위한 지원도 있습니다. 그들 모두 에 대한 npm install
문서 를 보십시오 .
git이 설치되어 있지 않으면 시도해 볼 수 있습니다.
npm install --save https://github.com/Amitesh/gulp-rev-all/tarball/master
npm install https://github.com/{USER}/{REPO}/tarball/{BRANCH}
다른 지점을 사용하는 것도 있습니다 .
2016 년 9 월 업데이트
이제 바닐라 https github URL에서 설치가 작동합니다.
npm install https://github.com/fergiemcdowall/search-index.git
EDIT: there are a couple of users commenting that you can't do this for all modules because you are reading from a source control system, which may well contain invalid/uncompiled/buggy code. So to be clear (although it should go without saying): given that the code in the repo is in an npm-usable state, you can now quite happily install directly from github
The current top answer by Peter Lyons is not relevant with recent NPM versions. For example, using the same command that was criticized in this answer is now fine.
$ npm install https://github.com/visionmedia/express
If you have continued problems it might be a problem with whatever package you were using.
The methods are covered pretty well now in npm's install documentation as well as the numerous other answers here.
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>]
However, something notable that has changed recently is npm adding the prepare
script to replace the prepublish
script. This fixes a longstanding problem where modules installed via git did not run the prepublish
script and thus did not complete the build steps that occur when a module is published to the npm registry. See https://github.com/npm/npm/issues/3055.
Of course, the module authors will need to update their package.json to use the new prepare
directive for this to start working.
UPDATE now you can do: npm install git://github.com/foo/bar.git
or in package.json
:
"dependencies": {
"bar": "git://github.com/foo/bar.git"
}
The general form of the syntax is
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
which means for your case it will be
npm install git+ssh://git@github.com/visionmedia/express.git
From npmjs docs:
npm install :
Installs the package from the hosted git provider, cloning it with git. For a full git remote url, only that URL will be attempted.
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish>
| #semver:] is one of git, git+ssh, git+http, git+https, or git+file.
If # is provided, it will be used to clone exactly that commit. If the commit-ish has the format #semver:, can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither # or
semver: is specified, then master is used.
If the repository makes use of submodules, those submodules will be cloned as well.
If the package being installed contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.
The following git environment variables are recognized by npm and will be added to the environment when running git:
- GIT_ASKPASS
- GIT_EXEC_PATH
- GIT_PROXY_COMMAND
- GIT_SSH
- GIT_SSH_COMMAND
- GIT_SSL_CAINFO GIT_SSL_NO_VERIFY
See the git man page for details.
Examples:
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
Install it directly:
npm install visionmedia/express
Alternatively, you can add "express": "github:visionmedia/express"
to the "dependencies"
section of package.json
file, then run:
npm install
You could also do
npm i alex-cory/fasthacks
or
npm i github:alex-cory/fasthacks
Basically:
npm i user_or_org/repo_name
You can directly install an github repo by npm install
command, like this: npm install https://github.com/futurechallenger/npm_git_install.git --save
NOTE: In the repo which will be installed by npm command:
- maybe you have to have a dist folder in you repo, according to @Dan Dascalescu's comment.
- You definitely have to have a package.json in you repo! which I forget add.
Simple :
npm install *GithubUrl*.git --save
example :
npm install https://github.com/visionmedia/express.git --save
I tried npm install git+https://github.com/visionmedia/express
but that took way too long and I wasn't sure that would work.
What did work for me was - yarn add git+https://github.com/visionmedia/express
.
Try this command
npm install github:[Organisation]/[Repository]#[master/BranchName] -g
this command worked for me.
npm install github:BlessCSS/bless#3.x -g
참고URL : https://stackoverflow.com/questions/17509669/how-to-install-an-npm-package-from-github-directly
'code' 카테고리의 다른 글
{this.props.children}에 소품을 전달하는 방법 (0) | 2020.09.29 |
---|---|
IMG와 CSS 배경 이미지는 언제 사용합니까? (0) | 2020.09.29 |
Java에서 메소드 실행 시간을 어떻게 측정합니까? (0) | 2020.09.29 |
Android에서 사용자의 현재 위치를 얻는 가장 간단하고 강력한 방법은 무엇입니까? (0) | 2020.09.29 |
PostgreSQL 데이터베이스의 모든 테이블을 삭제하려면 어떻게해야합니까? (0) | 2020.09.28 |