Trying to install modules from github results in:
ENOENT error on package.json.
Easily reproduced using express:
The current top answer by Peter Lyons is not relevant with recent NPM versions. For example, using the same command that was criticized in this answer is now fine.
$ npm install https://github.com/visionmedia/express
If you have continued problems it might be a problem with whatever package you were using.
The methods are covered pretty well now in npm's install documentation as well as the numerous other answers here.
npm install git+ssh://git@github.com:<githubname>/<githubrepo.git[#<commit-ish>]
npm install git+ssh://git@github.com:<githubname>/<githubrepo.git>[#semver:^x.x]
npm install git+https://git@github.com/<githubname>/<githubrepo.git>
npm install git://github.com/<githubname>/<githubrepo.git>
npm install github:<githubname>/<githubrepo>[#<commit-ish>]
However, something notable that has changed recently is npm adding the prepare
script to replace the prepublish
script. This fixes a longstanding problem where modules installed via git did not run the prepublish
script and thus did not complete the build steps that occur when a module is published to the npm registry. See https://github.com/npm/npm/issues/3055.
Of course, the module authors will need to update their package.json to use the new prepare
directive for this to start working.
I tried npm install git+https://github.com/visionmedia/express
but that took way too long and I wasn't sure that would work.
What did work for me was - yarn add git+https://github.com/visionmedia/express
.
Install it directly:
npm install visionmedia/express
Alternatively, you can add "express": "github:visionmedia/express"
to the "dependencies"
section of package.json
file, then run:
npm install
You could also do
npm i alex-cory/fasthacks
or
npm i github:alex-cory/fasthacks
Basically:
npm i user_or_org/repo_name
If git is not installed, we can try
npm install --save https://github.com/Amitesh/gulp-rev-all/tarball/master