npm 安装没有 package.json 的 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15143173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:14:56  来源:igfitidea点击:

npm install git repository without package.json

gitnpm

提问by Marc J. Schmidt

I have a project that depends on several third-party libs.

我有一个依赖于几个第三方库的项目。

My package.json looks like:

我的 package.json 看起来像:

"dependencies": {
    "vendor-name": "git://github.com/vendor/name.git#v1.1",
    ...
}

This works as long as the vendor-namerepository contains a package.json.

只要vendor-name存储库包含package.json.

If there's not such a file, I get:

如果没有这样的文件,我得到:

npm ERR! path /var/folders/0l/temp-folder/package.json
npm ERR! code ENOENT

Actually, a npm install git://github.com/vendor/name.git#v1.1does not work, too.

实际上, anpm install git://github.com/vendor/name.git#v1.1也不起作用。

So my question is: Is there a way to install (include) git repositories (in the dependencies) that do not have a package.json?

所以我的问题是:有没有办法安装(包括)没有 的 git 存储库(在dependenciespackage.json

回答by cyberwombat

Yes you can with this package: https://npmjs.org/package/napa

是的,你可以使用这个包:https: //npmjs.org/package/napa

回答by hakatashi

What napa do seems to be overengineered. I think just adding install script into the package.json is enough for you.

纳帕所做的似乎是过度设计的。我认为只需将安装脚本添加到 package.json 中就足够了。

"scripts": {
    "install": "git clone https://github.com/vendor/name.git -b v1.1 node_modules/name"
}

回答by ExxKA

no that is not possible according to the npm documentation

不,根据npm 文档,这是不可能的