npm install git repository without package.json

2019-02-03 01:29发布

问题:

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

My package.json looks like:

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

This works as long as the vendor-name repository contains a 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.1 does not work, too.

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

回答1:

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



回答2:

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

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


回答3:

no that is not possible according to the npm documentation



标签: git npm