3 ms·
I found the versions a bigger problem. I install something --save and get "^1.0.0" into my package.json, which resolves to 1.0.0 Someone installs my stuff and
by k__ 11y ago
I found the versions a bigger problem.
I install something --save and get "^1.0.0" into my package.json, which resolves to 1.0.0
Someone installs my stuff and on her machine it resolves to 1.0.3 and nothing works anymore, even if she cloned an exact copy of my repository etc.
Next step is to lock down all versions in my package.json, so all wildcards are gone.
But the packages I depend on still have wildcards and can break happily.
This happens far too often for my taste and can (as far as I know) only be solved with third party software.
- hunterloftis 11y agoYou can solve it with the npm shrinkwrap workflow mentioned in the article. It takes somewhat more effort, but locks down the full dependency tree. People have historically experienced a lot of issues with shrinkwrap in older versions of npm; I'm optimistic that npm 3 solves a lot of them.
- k__ 11y agoYes, I hope for npm3 too, but at the moment everyone in my team tells me it is far to slow to use it for anything :\
- mkozlows 11y agoThis is what you want to happen. The alternative is, you shrinkwrap everything and lock it down, and your dependencies never change. Except that now it's been a year, and you want to update your dependencies, and it's this huge jump that requires so many changes that it's going to take a month of concentrated pain to do, so you never do it, and welcome to the world of legacy code. Take your dependency-update hits in small bursts on the regular, and only lock down (via shrinkwrap or Docker images) for QA/release builds.
- iamsohungry 11y ago> This is what you want to happen. Uh, no, I don't want my dependencies to break out from under me, thanks. This is a major problem with the JS culture that I cannot stand. Too many JS devs can't be bothered to write software that doesn't suck, and so they try to instead tell their users their crappy problems are actually what they want. No, if you push changes to a library that break your library users' software without warning and a reasonable upgrade plan, you're doing a bad job. > The alternative is, you shrinkwrap everything and lock it down, and your dependencies never change. Or I use dependencies that upgrade their dependencies intentionally instead of whenever the `^` does it for them. The problem is that most of the JS packages out there are garbage software that doesn't do that. So it's necessary to be careful and only use dependencies which are well-maintained and reliable. ...which isn't unique to npm or a new problem, it's been well-known since all the way back when CPAN was new. Just because installing libraries is easy doesn't mean it's a good idea. > Except that now it's been a year, and you want to update your dependencies, and it's this huge jump that requires so many changes that it's going to take a month of concentrated pain to do, so you never do it, and welcome to the world of legacy code. Or you can do your job like a competent professional and don't wait a year to upgrade your dependencies. Again, fewer, more reliable dependencies helps with this; if you are using reasonable dependencies, they'll push few breaking changes and give warnings and reasonable upgrade plans.
- k__ 11y agoSo true... But I have to admit, the problems I mentioned only occur about once a month and only cost a few hours to fix and we have over 100 dependencies. If we wouldn't use so much third party stuff we would probably end up fixing this every few months, which is okay-ish.
- draw_down 11y agoPick your poison, locked down deps that you constantly change the x.x.1 version of, or the potential for the situation you describe. That actually isn't supposed to happen, because semver means don't do anything breaking in a patch release (or a minor release). Not that the system works perfectly, of course.