2015-12-23 44 views
10

我試圖用一個私人GitLab回購爲NPM依賴於我的節點JS的應用程序,配有私人令牌密鑰,這樣的事情:如何通過HTTPS使用私有GitLab庫與私人標記NPM的依賴

"dependencies": { 
    "my-module": "git+https://<privateToken>:[email protected]<myGitLabURL>/<MyUser>/my-module.git" 
} 

當我運行npm install我得到錯誤的git克隆與fatal: unable to access <git repo path>與443連接被拒絕的答覆。

我找不到很多關於如何通過https而不是通過ssh執行此操作的文檔。 看起來好像it does work on GitHub

有人在GitLab上使用Https的經驗嗎?

+2

我用這篇文章,它爲我工作。 http://stackoverflow.com/questions/28728665/how-to-use-private-github-repo-as-npm-dependency –

+1

您需要在項目的「部署密鑰」中註冊您的公鑰。很久以前,在那裏一個帶有令牌的網址,讓你只讀https訪問(所以npm安裝),但它不再起作用。它就像「git + https:// gitlab-ci-token:[email protected]/user/project.git --branch 2.0.0」。據我所知,現在唯一實際(並且安全)的方式是「部署密鑰」方式。 – Carlos

+0

[如何使用私有Github repo作爲npm依賴項]的可能的副本(https://stackoverflow.com/questions/28728665/how-to-use-private-github-repo-as-npm-dependency) –

回答

4

這個answer爲我工作。

"my-module": "https://oauth2:<PersonalAccessToken>@gitlab.com/<group>/<repository-name>.git 

您可以在用戶設置 - >訪問令牌(GitLab.com Link)創建個人訪問令牌。