Angular 2,从Github存储库安装库

时间:2017-03-14 21:13:00

标签: angular typescript github npm

我正在学习如何基于使用Angular-CLI创建的项目创建Angular 2库。我将通过Nikita Smolenskii的这些例子ng-demo-libng-demo-app

库依赖项在package.json中列出如下:

"ng-demo-lib": "git+ssh://git@github.com/nsmolenskii/ng-demo-lib.git",

问题是,当我在ng-demo-app上运行npm install时,我得到:

npm ERR! git clone --template=/Users/xxx/.npm/_git-remotes/_templates --mirror ssh://git@github.com/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://git@github.com/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://git@github.com/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://git@github.com/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://git@github.com/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://git@github.com/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://git@github.com/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知道我的身份吗?如何解决此权限问题?

1 个答案:

答案 0 :(得分:0)

尝试像这样{ "dependencies": { "repo-name": "github:user-name/repo-name" } } 安装表单github,或者在package.json文件中定义如下:

npm install

然后运行{{1}}