npm install not installing latest version on GitHub npm install not installing latest version on GitHub node.js node.js

npm install not installing latest version on GitHub


By default, NPM dependencies are pulled from the NPM repository. Authors must manually upload new versions of their software to the NPM repository, so the "@latest" version of the code hosted on NPM is different from the latest version of the code that exists anywhere (e.g., on GitHub).

According to the NPM repository's info page on Sails, the latest NPM-hosted version is 0.9.16 while the current GitHub version is 0.10.0-rc3.

If you want to have your project depend upon a particular branch or commit of a particular Git repo (instead of the version(s) hosted on the NPM repository), the NPM developers have included an explicit mechanism to allow this, detailed in "Git URLs as Dependencies" in the package.json docs:

Git URLs as Dependencies

Git urls can be of the form:

git://github.com/user/project.git#commit-ishgit+ssh://user@hostname:project.git#commit-ishgit+ssh://user@hostname/project.git#commit-ishgit+http://user@hostname/project/blah.git#commit-ishgit+https://user@hostname/project/blah.git#commit-ish

The commit-ish can be any tag, sha, or branch which can be supplied as an argument to git checkout. The default is master.

In fact, it's easier still to use a Github.com repo as a dependency:

As of version 1.1.65, you can refer to GitHub urls as just "foo": "user/foo-project". For example:

{  "name": "foo",  "version": "0.0.0",  "dependencies": {    "express": "visionmedia/express"  }}

So, to use the Sails GitHub repo, simply use:

"dependencies": {  "sails": "balderdashy/sails-mongo",  ...}

And to use the exact state of Sails as it exists on GitHub as of April 28, 2014, use:

"dependencies": {  "sails": "git://github.com/balderdashy/sails-mongo#b9cdce9a48",  ...}


I had a similar issue. Via the NPM Registry I was trying to get the latest from a project I saw in in GitHub, like this:

//package.json"devDependencies": {    "foo-package": "^3.3.0",}

But the code I got back from npm install (as observed in the node_modules/ folder) was not what I saw in GitHub repository's master branch. I was confused; as the two didn't match.

I eventually found: https://docs.npmjs.com/cli/view, which reveals some information (versions and dates) of what the NPM Registry is aware of for a particular repository.

// Console examplenpm view foo-package

After confirming that what I wanted from GitHub repository's master branch wasn't in the NPM Registry, I eventually changed my approach Git URLs as Dependencies, just as @apsillers answers.