简体   繁体   中英

npm error trying to install git repository

Having followed another SO, I am trying to include the latest version of a git repo (LeafletJS) that has yet to be pushed to npm.

The packages.config snipped:

"dependencies": {
 "leaflet": "git+https://{git hub generated token}:x-oauth-basic@github.com/Leaflet/Leaflet.git",

then,

npm install

reports

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:206: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:877:16)

npm WARN addRemoteGit at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

npm WARN addRemoteGit git+https://{token}:x-oauth-basic@github.com/Leaflet/Leaflet.git resetting remote C:\\Users\\bob\\AppData\\Roaming\\npm-cache_git-remotes\\git-https-{token}-x-oauth-basic- github-com-Leaflet-Leaflet-git-b27a5a7d 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:206: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:877: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' }

Doing a simple:

$ npm install --save https://github.com/Leaflet/Leaflet.git

correctly installs the latest master version from Leaflet repository (ie git+https://github.com/Leaflet/Leaflet.git#66cf6a0ea1df84dfcae441e91a9aa3bd66531030 at time of writing)

That being said, fetching Leaflet from the source repository might not be the best option for your need unfortunately. Indeed, you will not get the dist files. And trying to build them from your node_modules directory might not work, because the Leaflet build process uses git-rev-sync , which needs to be run in a git version controlled folder, which is not the case of your package when fetched through npm

But you can very easily manually download the current master version on this link:

https://leafletjs-cdn.s3.amazonaws.com/content/leaflet/master/leaflet.zip

(dev version link at the top of Leaflet download page )

You can also use them through CDN:

<link href="https://leafletjs-cdn.s3.amazonaws.com/content/leaflet/master/leaflet.css" rel="stylesheet" type="text/css" />
<script src="https://leafletjs-cdn.s3.amazonaws.com/content/leaflet/master/leaflet-src.js"></script>

(you will not keep that for production, as these files will keep on changing…)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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