2017-03-14 122 views
1

我正在學習如何基於Angular-CLI創建的項目創建一個Angular 2庫。我要通過Nikita Smolenskii的這些例子ng-demo-libng-demo-appAngular 2,從Github存儲庫安裝庫

庫相關列出像這樣的package.json:

"ng-demo-lib": "git+ssh://[email protected]/nsmolenskii/ng-demo-lib.git", 

的問題是,當我運行NPM在NG-演示應用程序安裝,我得到:

npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b: Cloning into bare repository '/Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b'... 
npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b: Permission denied (publickey). 
npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b: fatal: Could not read from remote repository. 
npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b: 
npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b: Please make sure you have the correct access rights 
npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b: and the repository exists. 
npm ERR! Darwin 16.4.0 
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" 
npm ERR! node v7.5.0 
npm ERR! npm v4.1.2 
npm ERR! code 128 

npm ERR! Command failed: git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://[email protected]/nsmolenskii/ng-demo-lib.git /Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b 
npm ERR! Cloning into bare repository '/Users/xxx/.npm/_git-remotes/git-ssh-git-github-com-nsmolenskii-ng-demo-lib-git-ea5cc26b'... 
npm ERR! Permission denied (publickey). 
npm ERR! fatal: Could not read from remote repository. 
npm ERR! 
npm ERR! Please make sure you have the correct access rights 
npm ERR! and the repository exists. 
npm ERR! 
npm ERR! 
npm ERR! If you need help, you may report this error at: 
npm ERR!  <https://github.com/npm/npm/issues> 

npm ERR! Please include the following file with any support request: 
npm ERR!  /Users/xxx/Desktop/nsmolenskii/ng-demo-app/npm-debug.log 

我我從未嘗試從package.json中的遠程存儲庫導入。這對我來說是新的。有什麼我需要建立,讓Github知道我的身份?我如何解決這個權限問題?

回答

0

嘗試在您的package.json文件安裝形式github上這樣npm i -D github:user-name/repo-name,或定義是這樣的:

{ 
    "dependencies": { 
    "repo-name": "github:user-name/repo-name" 
    } 
} 

然後運行npm install

+0

這並不能真正解決這個問題,因爲我需要的庫從package.json安裝。 – BBaysinger

+0

看到我的更新回覆。 – zhimin