npm package.json의 종속성으로 개인 github 리포지토리를 설치합니다.
다른 개인 github 저장소를 종속성으로 포함하는 npm으로 github 개인 저장소를 설치하려고합니다.
많은 방법과 게시물을 시도했지만 아무것도 작동하지 않습니다. 내가하고있는 일은 다음과 같습니다.
npm install git+https://github.com/myusername/mygitrepository.git
package.json의 내용은 다음과 같습니다.
"dependencies": {
"repository1name": "git+https://github.com/myusername/repository1.git",
"repository2name": "git+https://github.com/myusername/repository2.git"
}
올바른 방법은 무엇입니까?
이 시도:
"dependencies" : {
"name1" : "git://github.com/user/project.git#commit-ish",
"name2" : "git://github.com/user/project.git#commit-ish"
}
visionmedia / express가 name / repo 인 경우에도 시도 할 수 있습니다.
"dependencies" : {
"express" : "visionmedia/express"
}
또는 (npm 패키지 모듈이있는 경우) :
"dependencies" : {
"name": "*"
}
NPM 문서 에서 가져온
다음은 내가 필요한 모든 시나리오에서 잘 작동했습니다.
"dependencies": {
"GitRepo": "git+https://<token-from-github>:x-oauth-basic@github.com/<user>/<GitRepo>.git"
}
npm 문서에서 공개 디렉토리로 온 사람들은 https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
의존성으로 Git URL
힘내 URL은 다음과 같은 형식 일 수 있습니다.
git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish
commit-ish는 git checkout의 인수로 제공 할 수있는 모든 태그, sha 또는 분기 일 수 있습니다. 디폴트는 master입니다.
수락 된 답변은 효과가 있지만 안전한 토큰을 붙여 넣는 아이디어는별로 좋지 않습니다. package.json
다른 곳에서 찾았습니다 .git-config 맨 페이지에 설명 된 대로이 일회용 명령 을 실행하십시오 .
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf git@github.com:
GITHUB_TOKEN
environmnet 변수로 설정되거나 직접 붙여 넣기 가능
그런 다음 개인 github repos를 다음과 같이 설치합니다. npm install user/repo --save
Heroku에서도 작동합니다. 위의 git config ...
명령을 heroku-prebuild
스크립트로 package.json
설정 GITHUB_TOKEN
하고 Heroku 구성 변수로 설정하십시오.
사람들이 지적한대로 여러 가지 방법이 있지만 가장 짧은 버전은 다음과 같습니다.
// from master
"depName": "user/repo",
// specific branch
"depName": "user/repo#branch",
// specific commit
"depName": "user/repo#commit",
예 :
"dependencies" : {
"hexo-renderer-marked": "amejiarosario/hexo-renderer-marked#patch-1",
"hexo-renderer-marked": "amejiarosario/hexo-renderer-marked#2249507",
"hexo-renderer-marked": "amejiarosario/hexo-renderer-marked",
}
"dependencies": {
"some-package": "github:github_username/some-package"
}
아니면 그냥
"dependencies": {
"some-package": "github_username/some-package"
}
https://docs.npmjs.com/files/package.json#github-urls
Since Git uses curl
under the hood, you can use ~/.netrc
file with the credentials. For GitHub it would look something like this:
machine github.com
login <github username>
password <password OR github access token>
If you choose to use access tokens
, it can be generated from:
Settings -> Developer settings -> Personal access tokens
This should also work if you are using Github Enterprise in your own corporation. just put your enterprise github url in the machine
field.
Here is a more detailed version of how to use the Github token without publishing in the package.json
file.
- Create personal github access token
- Setup url rewrite in ~/.gitconfig
git config --global url."https://<TOKEN HERE>:x-oauth-basic@github.com/".insteadOf https://x-oauth-basic@github.com/
- Install private repository. Verbose log level for debugging access errors.
npm install --loglevel verbose --save git+https://x-oauth-basic@github.com/<USERNAME HERE>/<REPOSITORY HERE>.git#v0.1.27
In case access to Github fails, try running the git ls-remote ...
command that the npm install will print
For my private repository reference I didn't want to include a secure token, and none of the other simple (i.e. specifying only in package.json) worked. Here's what did work:
- Went to GitHub.com
- Navigated to Private Repository
- Clicked "Clone or Download" and Copied URL (which didn't match the examples above)
- Added #commit-sha
- Ran npm install
'Programming' 카테고리의 다른 글
파이썬의 모든 기능은 어떻게 작동합니까? (0) | 2020.05.14 |
---|---|
SQL Server에서 외래 키를 어떻게 삭제합니까? (0) | 2020.05.14 |
템플릿 코드 내에서 변수 값을 설정하는 방법은 무엇입니까? (0) | 2020.05.14 |
@ManyToOne JPA 연관에 대한 CascadeType.ALL의 의미는 무엇입니까 (0) | 2020.05.14 |
각 카테고리마다 상위 10 개 레코드를 선택하십시오. (0) | 2020.05.14 |