简体   繁体   English

npm 访问时出现安装错误 GIT url

[英]npm install giving error while accessing GIT url

my package.json has the following dependency,我的 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"
  }
}

when I execute npm install command, I am getting the following error,当我执行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>

I am new to node modules and git. Should i have to do any configuration related to GIT in node modules?我是节点模块和 git 的新手。我是否必须在节点模块中进行与 GIT 相关的任何配置?

[Edit]: I am behind a corporate proxy. [编辑]:我支持公司代理。 Should have to give any configuration related to that?应该提供与此相关的任何配置吗? I added proxy details in.npmrc file in users/<username>/.npmrc file.我在users/<username>/.npmrc文件中的 .npmrc 文件中添加了代理详细信息。 My path variable has the Git/bin location as well.我的路径变量也有 Git/bin 位置。

This question has an answer in an other thread .这个问题在另一个线程中有一个答案 The issue occurred since I was behind corporate proxy.问题发生是因为我落后于公司代理。 And @bnguyen82 's answer helped me finally. @bnguyen82的回答最终帮助了我。

I just used the following command and the issue got resolved.我刚刚使用了以下命令,问题就解决了。

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

The accepted answer alone did not help me.单独接受的答案对我没有帮助。 Finally it worked after I cleared the npm cache using npm cache clear .在我使用npm cache clear清除了 npm 缓存后,它终于起作用了。

1.check your internet connection 1.检查您的互联网连接
2.ping test to github.com in TERMINAL or CMD 2. 在 TERMINAL 或 CMD 中 ping 测试到 github.com
if everything is working fine then try to use this format for your git url git+https://git@github.com/geedmo/css-flip.git如果一切正常,请尝试将这种格式用于您的 git url git+https://git@github.com/geedmo/css-flip.git

or或者

if you need ssh:如果您需要 ssh:

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

我遇到了同样的问题,并且能够通过安装 git 来解决它

sudo apt-get install git-all

Git can not link to the specified URL. Git 无法链接到指定的 URL。 You can try git proxy mode.你可以试试git代理模式。 (Need their own proxy service) (需要自己的代理服务)

Settings:设置:

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

Cancel the setting:取消设置:

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

In non-interactive mode在非交互模式下

Git Bash in the folder where you want set up your project Git Bash 在您要设置项目的文件夹中

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

就我而言,git 没有安装在我的机器上。

  1. Just observe this "css-flip": "git://github.com/geedmo/css-flip" line in your package JSON code.只需在你的包 JSON 代码中观察这个"css-flip": "git://github.com/geedmo/css-flip"行。
  2. Your project depends upon a file css-flip which is stored in another project/repo.您的项目依赖于存储在另一个项目/存储库中的文件css-flip
  3. while installing npm, your package JSON file will try to access and download css-flip file of another repo but something might blocking it.在安装 npm 时,您的包 JSON 文件将尝试访问和下载另一个 repo 的css-flip文件,但某些东西可能会阻止它。
  4. In my case VPN blocked dependent files of other repo.在我的情况下, VPN阻止了其他 repo 的依赖文件。 So I initiated VPN and tried installing npm again npm i and it worked like magic.所以我启动了 VPN 并尝试再次安装 npm npm i并且它像魔术一样工作。

In my case, I'm in a Windows environment and I'm using nvm-windows and Cygwin .就我而言,我处于 Windows 环境中,并且我正在使用nvm-windowsCygwin I'd installed Cygwin's GIT version and I've got errors similar to those in the question regarding Error: Command failed: git .我已经安装了Cygwin 的 GIT 版本,但我遇到的错误与有关Error: Command failed: git的问题中的错误类似。

So, I uninstalled this version and installed GIT for Windows .所以,我卸载了这个版本并为 Windows 安装了 GIT Then I attempted npm i again and the problem was solved.然后我再次尝试npm i ,问题就解决了。

At last I kill the terminal and restart again and it worked!最后我杀了终端并重新启动,它成功了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM