简体   繁体   English

使用npm安装不是模块的库

[英]Installing a library with npm that is not a module

I working on a project that requires WebGazer.js ( https://webgazer.cs.brown.edu/ ). 我正在研究一个需要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. 我想以某种方式将此库添加到package.json,以便我所有的库都使用“ npm install”安装,而不必调用“ npm install”然后分别下载webgazer。

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的新手,所以我什至不知道从哪里开始或者是否有可能。

npm install only works on modules. npm install仅适用于模块。 But, WebGazer has a package.json for NPM which is all you need. 但是,WebGazer具有NPM的package.json,这是您所需要的。 (The module doesn't need to be listed in the NPM repository.) (不需要在NPM存储库中列出该模块。)

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. 如果您确实遇到了所描述的问题,则可以设置一个postinstall本来安装您需要的其他任何东西,但是您需要它。 https://docs.npmjs.com/misc/scripts 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: 对于那些想知道如何安装您自己创建且位于git上的non node_module依赖项的人:

Just add a package.json file to your (non-node_module) dependency looking at least like this: 只需将package.json文件添加到您的(non-node_module)依赖项中,至少看起来像这样:

{
  "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: 然后只需在您的“母亲”项目中遵循ryanve的 回答即可

It can be done via ssh or via https and oauth. 可以通过ssh或通过https和oauth完成。

https and oauth: create an access token that has "repo" scope and then use this syntax: https和oauth:创建具有“回购”范围的访问令牌,然后使用以下语法:

"package-name": "git+https://:x-oauth-basic@github.com//.git" ssh: setup ssh and then use this syntax: “ package-name”:“ git + https://:x-oauth-basic@github.com//.git” ssh:设置ssh,然后使用以下语法:

"package-name": "git+ssh://git@github.com//.git" “程序包名称”:“ git + ssh://git@github.com//.git”

(Thanks to what Brad said earlier). (感谢Brad先前所说的)。

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

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