【问题标题】:Unable to install an npm package无法安装 npm 包
【发布时间】:2017-12-12 06:05:21
【问题描述】:

我尝试了许多不同的方式来安装this 包: npm 安装云打印 npm 安装https://github.com/postmen/node-cloud-print.git 等等……

每次我得到以下输出:

`npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:211:12)
npm WARN addRemoteGit     at emitTwo (events.js:106:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:191:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:885:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm WARN addRemoteGit  git+ssh://git@github.com/postmen/google-api-nodejs-client.git resetting remote C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46 because of error: { Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit     at ChildProcess.exithandler (child_process.js:211:12)
npm WARN addRemoteGit     at emitTwo (events.js:106:13)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:191:7)
npm WARN addRemoteGit     at maybeClose (internal/child_process.js:885:16)
npm WARN addRemoteGit     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm WARN addRemoteGit   killed: false,
npm WARN addRemoteGit   code: 1,
npm WARN addRemoteGit   signal: null,
npm WARN addRemoteGit   cmd: 'git -c core.longpaths=true config --get remote.origin.url' }
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Cloning into bare repository 'C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46'...
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Host key verification failed.
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: fatal: Could not read from remote repository.
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46:
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: Please make sure you have the correct access rights
npm ERR! git clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46: and the repository exists.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "cloud-print"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code 128
npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror ssh://git@github.com/postmen/google-api-nodejs-client.git C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46
npm ERR! Cloning into bare repository 'C:\Users\User\AppData\Roaming\npm-cache\_git-remotes\git-ssh-git-github-com-postmen-google-api-nodejs-client-git-21a89f46'...
npm ERR! Host key verification failed.
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!     D:\Tmunot\npm-debug.log`

我也尝试将目录下载到 node_modules 并在 package.json 中手动配置,但我没有成功。

有什么想法吗?

【问题讨论】:

  • 什么输出?缺少一些文字
  • 我的缩进有问题,现在可以了
  • 如果是链接:尝试将其内容直接添加到您的问题并标记为代码
  • 从我看到的脚本通过 ssh 获取 repo 所以你需要注意这里Please make sure you have the correct access rights and the repository exists.
  • 我猜这是因为您使用的是 git+ssh:// 并且您的个人资料中没有 SSH。试试Connecting to GitHub with SSH

标签: node.js github npm npm-install package.json


【解决方案1】:

并非所有软件包都支持从 github 安装。如果是available in npm (correct package now linked),我会赞成。

如果它在 npm 中不可用,那么就知道它似乎有一个构建过程(假设存在grunt 命令)。您应该克隆它,构建它并使用 NPM 拉入“构建”副本。

一旦构建,您将使用此处描述的方法:npm install <folder>

【讨论】:

【解决方案2】:

我认为问题出在你的 npm 版本上。 npm 版本对于这个包来说太新了。包 cloud-print 已过时。没有人支持这个包。也许 be npm 会在 5.1 版本中支持那种类型的包。

JFYI:npm i cloud-print 不同节点+npm 版本的结果:

  • 节点 v8.1.3 npm v5.0.3 错误
  • node v7.10.0 npm v4.2.0 工作
  • 节点 v6.11.0 npm v3.10.10 工作
  • node v4.4.7 npm v2.15.8 工作

解决方案使用 Node.js v.6

您可以使用 Node.js v6 吗?在这个最新的支持版本上,你可以使用这个包。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 2020-09-06
    相关资源
    最近更新 更多