简体   繁体   中英

Installing a library with npm that is not a module

I working on a project that requires WebGazer.js ( https://webgazer.cs.brown.edu/ ). I would love to somehow add this library to package.json so that all my libraries install with 'npm install' instead of having to call 'npm install' and then download webgazer separately.

Is there anyway to do this by including a link or something of that nature? I am new to npm so I have no idea where to even start or if this is even possible.

npm install only works on modules. But, WebGazer has a package.json for NPM which is all you need. (The module doesn't need to be listed in the NPM repository.)

Try something like this:

npm install --save git+https://git@github.com/brownhci/WebGazer.git

If you actually had the problem you describe, you could set up a postinstall script to install anything else you needed, however you need it. https://docs.npmjs.com/misc/scripts

For those who want to know how to install a non node_module dependency that you created yourself and that's on git:

Just add a package.json file to your (non-node_module) dependency looking at least like this:

{
  "name": "your-dependency-name",
  "version": "1.0.0",
  "repository": {
    "type": "git",
    "url": "https://github.com/<user>/<repo>.git"
  }
}

Then just follow ryanve's answer in your 'mother' project:

It can be done via ssh or via https and oauth.

https and oauth: create an access token that has "repo" scope and then use this syntax:

"package-name": "git+https://:x-oauth-basic@github.com//.git" ssh: setup ssh and then use this syntax:

"package-name": "git+ssh://git@github.com//.git"

(Thanks to what Brad said earlier).

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