【问题标题】:npm install gets permission denied for a modulenpm install 获得模块的权限被拒绝
【发布时间】:2018-03-08 18:20:56
【问题描述】:

获取本地存储库的权限被拒绝错误,我可以成功克隆它,但是 npm install:npm install 出现错误

npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://git@stash.company.com:2222/castor/module-name.git
npm ERR!
npm ERR! git@stash.company.com: 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! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MOEL3\AppData\Roaming\npm-cache\_logs\2018-03-08T18_12_33_006Z-debug.log

但是,每次我执行有关远程 repo pull、push 等的 git 命令时,我都必须输入密码……这会是原因吗?如何解决这个问题?

【问题讨论】:

  • 如果您使用 ssh 连接到 GitHub,请尝试使用 eval $(ssh-agent -s) 后跟 ssh-add ~/.ssh/id_rsa,其中 id_rsa 是您的公钥。
  • 问题发生在 windows 而非 linux 上
  • 这些是 windows 指令,使用 Git Bash -> help.github.com/articles/…

标签: node.js git npm-install permission-denied bitbucket-server


【解决方案1】:

最近遇到这个问题,好郁闷……

我可以 git clone 一个私有 repo 没有问题,但是当我尝试通过 Visual Studio Code 安装一个包时,它就因为看起来像是一个身份验证错误而失败了。

git@github.com:权限被拒绝(公钥)。 致命:无法从远程存储库中读取。 请确保您拥有正确的访问权限 并且存储库存在。

为我解决的问题是以管理员身份打开 Sublime Text,在 C:ProgramFiles/Git/etc/ssh/ 文件夹中找到 ssh_config 文件,在 Admin sublime 窗口中打开它,然后在底部添加它

HOST github.com
IdentityFile /c/Users/me/.ssh/id_rsa

原来 npm install 在根文件夹中查找我的密钥,而不是在主文件夹中。告诉它从我的用户文件夹中的身份中获取密钥解决了这个问题。

希望这对其他人有帮助。

【讨论】:

    猜你喜欢
    • 2019-09-24
    • 1970-01-01
    • 2018-06-08
    • 2018-01-13
    • 2018-03-01
    • 2018-07-29
    • 2018-01-19
    • 2021-01-21
    • 2018-11-11
    相关资源
    最近更新 更多