17

I have a project with a local file dependency in my package.json like this:

"dependencies": {
    "dep_1": "file:../../dep_1"
  }
}

When I do npm install it is installed into node_modules. But if I make changes to dep_1 how do I update the module version in node_modules?

I tried doing npm update but nothing happens.

Sean Lynch
  • 2,852
  • 4
  • 32
  • 46

1 Answers1

18

If you are using a relatively new version of npm (I used version 2.14.2) you can bump the version number in package.json and npm update dep_1 should work. Otherwise how can npm know that something needs to be updated?

Note: This will only work if the version is higher than what has previously been installed. You will have to clean the cache to reset this behaviour.

However, you can forceably (and lazily) update local modules by simply running npm install again. e.g.

npm install dep_1

It should be fast since its on your local computer and you don't have to play around with version numbers.

For more detail see the discussion about this issue on the official npm repository page: https://github.com/npm/npm/issues/7426

chriskelly
  • 7,526
  • 3
  • 32
  • 50
  • 4
    Actually doing `npm install dep_1` doesn't work. Because `dep_1` isn't in the npm repository. But doing `npm install ../../dep_1` works perfectly. – Sean Lynch Sep 30 '15 at 19:39
  • @SeanLynch : ```npm install dep_1``` works for me here. I have npm version 2.14.2 and my line contains ```"dep_1" : "file:../dep_1"``` – chriskelly Sep 30 '15 at 19:46
  • @SeanLynch : Also, did you try bumping version and running ```npm update``` – chriskelly Sep 30 '15 at 19:47
  • I am using npm version 2.11.3. I tried to do a version bump and then doing the update but the behavior was the same. – Sean Lynch Sep 30 '15 at 20:10
  • @SeanLynch : Well, in any case, if I was developing locally I would probably stick with ```npm install``` update method since you don't have to go messing with your version. Also, maybe you should update your npm version to something newer. Bumping the version and using ```npm update``` works for me and more importantly, answers the question . I will update my answer to note that it may not work on older versions of npm. – chriskelly Sep 30 '15 at 20:18