从git仓库运行“npm install”包时出错

这是杀了我。 在命令行中input以下内容后:

> npm install git+https://github.com/jshint/jshint.git 

我得到下面的命令行错误

 npm ERR! addLocal Could not install D:\Users\Niko\AppData\Roaming\npm\npm_temp\npm-12692-e02bf6f0\git-cache-60d903b5b73a\561d9785cdca88fc0a3178795274207520d05596 npm ERR! Windows_NT 6.1.7601 npm ERR! argv "node" "D:\\Users\\Niko\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "git+https://github.com/jshint/jshint.git" npm ERR! node v0.12.4 npm ERR! npm v2.13.2 npm ERR! path D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz npm ERR! code ENOENT npm ERR! errno -4058 npm ERR! enoent ENOENT, scandir 'D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz' npm ERR! enoent This is most likely not a problem with npm itself npm ERR! enoent and is related to npm not being able to find a file. npm ERR! enoent npm ERR! Please include the following file with any support request: npm ERR! C:\repos\UNTRACKED\MyPackage\npm-debug.log 

npm-debug.log

 0 info it worked if it ends with ok 1 verbose cli [ 'node', 1 verbose cli 'D:\\Users\\Niko\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install', 1 verbose cli 'git+https://github.com/jshint/jshint.git' ] 2 info using npm@2.13.2 3 info using node@v0.12.4 4 verbose install initial load of C:\repos\UNTRACKED\MyPackage\package.json 5 verbose readDependencies loading dependencies from C:\repos\UNTRACKED\MyPackage\package.json 6 silly cache add args [ 'git+https://github.com/jshint/jshint.git', null ] 7 verbose cache add spec git+https://github.com/jshint/jshint.git 8 silly cache add parsed spec { raw: 'git+https://github.com/jshint/jshint.git', 8 silly cache add scope: null, 8 silly cache add name: null, 8 silly cache add rawSpec: 'git+https://github.com/jshint/jshint.git', 8 silly cache add spec: 'git+https://github.com/jshint/jshint.git', 8 silly cache add type: 'hosted', 8 silly cache add hosted: 8 silly cache add { type: 'github', 8 silly cache add ssh: 'git@github.com:jshint/jshint.git', 8 silly cache add sshUrl: 'git+ssh://git@github.com/jshint/jshint.git', 8 silly cache add httpsUrl: 'git+https://github.com/jshint/jshint.git', 8 silly cache add gitUrl: 'git://github.com/jshint/jshint.git', 8 silly cache add shortcut: 'github:jshint/jshint', 8 silly cache add directUrl: 'https://raw.githubusercontent.com/jshint/jshint/master/package.json' } } 9 verbose addRemoteGit caching git+https://github.com/jshint/jshint.git 10 verbose addRemoteGit git+https://github.com/jshint/jshint.git is a repository hosted by github 11 silly tryClone cloning git+https://github.com/jshint/jshint.git via git+https://github.com/jshint/jshint.git 12 verbose tryClone https-github-com-jshint-jshint-git-e872a8ff not in flight; caching 13 info git [ 'config', '--get', 'remote.origin.url' ] 14 silly validateExistingRemote git+https://github.com/jshint/jshint.git remote.origin.url: https://github.com/jshint/jshint.git 15 verbose validateExistingRemote git+https://github.com/jshint/jshint.git is updating existing cached remote D:\Users\Niko\AppData\Roaming\npm-cache\_git-remotes\https-github-com-jshint-jshint-git-e872a8ff 16 info git [ 'fetch', '-a', 'origin' ] 17 verbose updateRemote git fetch -a origin (https://github.com/jshint/jshint.git) 18 verbose setPermissions git+https://github.com/jshint/jshint.git skipping chownr on Windows 19 verbose resolveHead git+https://github.com/jshint/jshint.git original treeish: master 20 info git [ 'rev-list', '-n1', 'master' ] 21 silly resolveHead git+https://github.com/jshint/jshint.git resolved treeish: 561d9785cdca88fc0a3178795274207520d05596 22 verbose resolveHead git+https://github.com/jshint/jshint.git resolved Git URL: git+https://github.com/jshint/jshint.git#561d9785cdca88fc0a3178795274207520d05596 23 silly resolveHead Git working directory: D:\Users\Niko\AppData\Roaming\npm\npm_temp\npm-12692-e02bf6f0\git-cache-60d903b5b73a\561d9785cdca88fc0a3178795274207520d05596 24 info git [ 'clone', 24 info git 'D:\\Users\\Niko\\AppData\\Roaming\\npm-cache\\_git-remotes\\https-github-com-jshint-jshint-git-e872a8ff', 24 info git 'D:\\Users\\Niko\\AppData\\Roaming\\npm\\npm_temp\\npm-12692-e02bf6f0\\git-cache-60d903b5b73a\\561d9785cdca88fc0a3178795274207520d05596' ] 25 verbose cloneResolved git+https://github.com/jshint/jshint.git clone Cloning into 'D:\Users\Niko\AppData\Roaming\npm\npm_temp\npm-12692-e02bf6f0\git-cache-60d903b5b73a\561d9785cdca88fc0a3178795274207520d05596'... 25 verbose cloneResolved done. 26 info git [ 'checkout', '561d9785cdca88fc0a3178795274207520d05596' ] 27 verbose checkoutTreeish git+https://github.com/jshint/jshint.git checkout Note: checking out '561d9785cdca88fc0a3178795274207520d05596'. 27 verbose checkoutTreeish 27 verbose checkoutTreeish You are in 'detached HEAD' state. You can look around, make experimental 27 verbose checkoutTreeish changes and commit them, and you can discard any commits you make in this 27 verbose checkoutTreeish state without impacting any branches by performing another checkout. 27 verbose checkoutTreeish 27 verbose checkoutTreeish If you want to create a new branch to retain commits you create, you may 27 verbose checkoutTreeish do so (now or later) by using -b with the checkout command again. Example: 27 verbose checkoutTreeish 27 verbose checkoutTreeish git checkout -b new_branch_name 27 verbose checkoutTreeish 27 verbose checkoutTreeish HEAD is now at 561d978... Merge branch 'lukeapage/default-params' 28 verbose addLocalDirectory D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz not in flight; packing 29 verbose tar pack [ 'D:\\Users\\Niko\\AppData\\Roaming\\npm-cache\\jshint\\2.8.0\\package.tgz', 29 verbose tar pack 'D:\\Users\\Niko\\AppData\\Roaming\\npm\\npm_temp\\npm-12692-e02bf6f0\\git-cache-60d903b5b73a\\561d9785cdca88fc0a3178795274207520d05596' ] 30 verbose tarball D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz 31 verbose folder D:\Users\Niko\AppData\Roaming\npm\npm_temp\npm-12692-e02bf6f0\git-cache-60d903b5b73a\561d9785cdca88fc0a3178795274207520d05596 32 error addLocal Could not install D:\Users\Niko\AppData\Roaming\npm\npm_temp\npm-12692-e02bf6f0\git-cache-60d903b5b73a\561d9785cdca88fc0a3178795274207520d05596 33 verbose stack Error: ENOENT, scandir 'D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz' 33 verbose stack at Error (native) 34 verbose cwd C:\repos\UNTRACKED\MyPackage 35 error Windows_NT 6.1.7601 36 error argv "node" "D:\\Users\\Niko\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "git+https://github.com/jshint/jshint.git" 37 error node v0.12.4 38 error npm v2.13.2 39 error path D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz 40 error code ENOENT 41 error errno -4058 42 error enoent ENOENT, scandir 'D:\Users\Niko\AppData\Roaming\npm-cache\jshint\2.8.0\package.tgz' 42 error enoent This is most likely not a problem with npm itself 42 error enoent and is related to npm not being able to find a file. 43 verbose exit [ -4058, true ] 

(jshint只是一个例子;我真的需要能够从我的局域网上的私人git仓库安装软件包)

使用以下语法:

 npm install git://github.com/user/repo.git 

例如:

 npm install git://github.com/substack/node-mkdirp.git 

或者在这种情况下:

 npm install git://github.com/jshint/jshint.git 

根据需要设置npm代理:

 npm config set proxy http://username:password@proxy.company.com:1234 npm config set https-proxy http://username:password@proxy.company.com:4567 

如果需要的话,git代理:

 git config --global http.proxy proxy.company.com:1234 

参考

  • npm文档
  • Git – git-config文档