【问题标题】:npm install giving error while accessing GIT urlnpm install 在访问 GIT url 时出错
【发布时间】:2015-10-23 01:19:13
【问题描述】:

我的 package.json 有以下依赖,

    {
  "name": "AppName",
  "version": "0.0.0",
  "description": "App Description",
  "author": "@author",
  "dependencies": {},
  "devDependencies": {
    "css-flip": "git://github.com/geedmo/css-flip",
    "gulp": "^3.8.10",
    "gulp-angular-htmlify": "^0.4.0",
    "gulp-changed": "^1.1.0",
    "gulp-compass": "^2.0.4",
    "gulp-concat": "^2.4.1",
    "gulp-css-flip": "^0.4.0",
    "gulp-expect-file": "0.0.7",
    "gulp-filter": "^1.0.2",
    "gulp-html-prettify": "0.0.1",
    "gulp-if": "^1.2.5",
    "gulp-ignore": "^1.2.1",
    "gulp-jade": "^0.8.0",
    "gulp-jsvalidate": "^2.0.0",
    "gulp-less": "^1.3.9",
    "gulp-livereload": "^2.1.1",
    "gulp-load-plugins": "^0.10.0",
    "gulp-minify-css": "^0.3.11",
    "gulp-ng-annotate": "^0.4.3",
    "gulp-rename": "^1.2.0",
    "gulp-sass": "^1.3.2",
    "gulp-sourcemaps": "^1.3.0",
    "gulp-sync": "^0.1.4",
    "gulp-uglify": "^1.1.0",
    "gulp-util": "^3.0.1",
    "marked": "^0.3.2",
    "through2": "^0.6.3",
    "yargs": "^3.7.2"
  },
  "scripts": {
    "prestart": "bower install",
    "start": "npm install",
    "poststart": "gulp"
  }
}

当我执行npm install 命令时,出现以下错误,

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:751:12)
npm WARN addRemoteGit     at ChildProcess.emit (events.js:110:17)
npm WARN addRemoteGit     at maybeClose (child_process.js:1015:16)
npm WARN addRemoteGit     at Socket.<anonymous> (child_process.js:1183:11)
npm WARN addRemoteGit     at Socket.emit (events.js:107:17)
npm WARN addRemoteGit     at Pipe.close (net.js:485:12)
npm WARN addRemoteGit  git://github.com/geedmo/css-flip.git resetting remote C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remotes\git-github-com-geedmo-css-flip-git-3c35004c because of error: {
 [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url
npm WARN addRemoteGit ]
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\drj8cob\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/geedmo/css-flip.git C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remot
es\git-github-com-geedmo-css-flip-git-3c35004c: Cloning into bare repository 'C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remotes\git-github-com-geedmo-css-flip-git-3c35004c'...
npm ERR! git clone --template=C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/geedmo/css-flip.git C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remot
es\git-github-com-geedmo-css-flip-git-3c35004c: fatal: Unable to look up github.com (port 9418) (No such host is known. )
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code 128

npm ERR! Command failed: git -c core.longpaths=true clone --template=C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/geedmo/css-flip.git C:\Users\drj8c
ob\AppData\Roaming\npm-cache\_git-remotes\git-github-com-geedmo-css-flip-git-3c35004c
npm ERR! Cloning into bare repository 'C:\Users\drj8cob\AppData\Roaming\npm-cache\_git-remotes\git-github-com-geedmo-css-flip-git-3c35004c'...
npm ERR! fatal: Unable to look up github.com (port 9418) (No such host is known. )
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

我是节点模块和 git 的新手。我是否必须在节点模块中进行与 GIT 相关的任何配置?

[编辑]:我是公司代理的幕后黑手。应该提供与此相关的任何配置吗?我在 users/&lt;username&gt;/.npmrc 文件的 .npmrc 文件中添加了代理详细信息。我的路径变量也有 Git/bin 位置。

【问题讨论】:

  • 能否给出package.json文件的全部内容?
  • @Deepak Biswal,我已经给出了package.json文件的全部内容。
  • 嘿,我试着在最后运行它,一切似乎都运行良好!
  • npm install --verbose 根据here

标签: node.js git npm


【解决方案1】:

1.检查您的互联网连接
2.在TERMINAL或CMD中对github.com进行ping测试
如果一切正常,请尝试 将此格式用于您的 git url git+https://git@github.com/geedmo/css-flip.git

如果你需要 ssh:

git+ssh://git@github.com/visionmedia/express.git

【讨论】:

  • 前者给出致命:无法访问git@github.com/geedmo/css-flip.git:无法解析主机:github.com,后者给出ssh: Could not resolve hostname github.com: no address associated with name
  • 检查一次网络连接
  • 我在公司代理后面。我应该提供一些配置吗?我在 .npmrc 文件中给出了代理详细信息。
  • 这个错误是基本的,它没有解析 github.com,这意味着它不在互联网上。
  • 只需在您的 CMD 或 TERMINAL 中测试为“ping github.com”
【解决方案2】:

这个问题在另一个thread有答案。自从我支持公司代理以来,就出现了这个问题。 @bnguyen82 的回答终于帮助了我。

我刚刚使用了以下命令,问题就解决了。

git config --global url."https://".insteadOf git://

【讨论】:

  • 我通过删除 https:// 周围的引号使这个配置工作,如下所示: git config --global url.https://.insteadOf git://
【解决方案3】:

我遇到了同样的问题,通过安装 git 解决了它

sudo apt-get install git-all

【讨论】:

    【解决方案4】:

    Git 无法链接到指定的 URL。你可以试试 git 代理模式。 (需要自己的代理服务)

    设置:

    git config –global http.proxy http://127.0.0.1:1080 
    git config –global https.proxy https://127.0.0.1:1080 
    

    取消设置:

    git config –global –unset http.proxy 
    git config –global –unset https.proxy
    

    【讨论】:

      【解决方案5】:

      仅接受的答案对我没有帮助。最后,在我使用npm cache clear 清除 npm 缓存后它工作了。

      【讨论】:

      • As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use "npm install --cache /tmp/empty-cache" to use a temporary cache instead of nuking the actual one. 10.x 版本上的输出
      【解决方案6】:

      在非交互模式下

      Git Bash 在您要设置项目的文件夹中

      expo init AwesomeProject --template blank --workflow managed --name yourappname
      

      【讨论】:

        【解决方案7】:

        在我的情况下,我的机器上没有安装 git。

        【讨论】:

          【解决方案8】:
          1. 请注意您的包 JSON 代码中的 "css-flip": "git://github.com/geedmo/css-flip" 行。
          2. 您的项目依赖于一个文件css-flip,该文件存储在另一个项目/存储库中。
          3. 在安装 npm 时,您的包 JSON 文件将尝试访问和下载另一个 repo 的 css-flip 文件,但可能会被阻止。
          4. 在我的例子中 VPN 阻止了其他 repo 的依赖文件。所以我启动了 VPN 并尝试再次安装 npm npm i,它就像魔术一样工作。

          【讨论】:

            猜你喜欢
            • 2020-12-01
            • 2018-11-22
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-02-20
            • 1970-01-01
            相关资源
            最近更新 更多