Home / GitHub Page

Migrating to yarn instead of npm

Just a head up that I’ll probably switch to the yarn package manager soon. The goal is mainly to get more stable and reproducible builds, and to avoid playing yoyo with package-lock.json.

I’m also hoping yarn provides more sensible error messages when there’s a problem (it’s very likely it’s better because it can’t be worse than npm anyway).

So if you build the app from source, you’ll just need to start using yarn install instead of npm install but other than that there shouldn’t be any changes.

3 Likes

Also, the common consensus is that using multiple node package managers can lead to problems long-term. If you move to yarn as the full package manager, though, do you know if all of the packages used are compatible with it? When I tried to install some of them with it last time, I found that yarn didn’t pull all of the dependencies in.

I’ve done a few tests and as far as can see there was no problem with any of them.

Also, the common consensus is that using multiple node package managers can lead to problems long-term.

Yes, but we would switch everything to yarn. Currently we are using npm for everything, except for building the Electron app as this requires yarn. With that change it would be yarn for everything.

I actually use npm run dist.

I remember I had massive issues with yarn at one point, but if it streamlines the build process, who am I to argue.

Main reason to switch is to avoid this npm bug where it changes package-lock on each install even though the dependencies haven’t changed.

Do you remember what issues you had in particular with yarn?

@bedwardly-down, I will create a pull request before switching to yarn. Perhaps you could try from that PR if it’s still working fine in Linux?

Unfortunately not. That was a long time ago, so I’m hopeful these issues have been resolved. Theoretically yarn should be a better solution. Faster and being able to de-duplicate stuff, but we’ll see how it will fare.

I’ve done some further reading and I’ve decided not to switch in the end. Both have their pros and cons and at least with npm we know what to expect, while with yarn there will be new issues we’ll have to figure out.

If that works now, we should switch to it on CI then. Before, there was definitely a bug as electron-builder was only tested with yarn and didn’t work properly with npm. Maybe it has changed since then.

1 Like

@laurent, I’m sorry. After getting the 5.5 kernel issue resolved finally (latest kernel release fixed it), I’ve decided to step out of the Linux scene for a bit. It’s just not a valuable usage of my time right now since i have career goals that Linux just won’t cut it for right now.

Also, the package that yarn had problems with the most when i tested it was the sqlite3 one. It wasn’t pulling in all required dependencies, but that may have been resolved since.

Sure, no problem, and as mentioned above we’ll stay with npm for now anyway. It’s not perfect but works well enough.

1 Like

If the footprint of node packages that are required could be shrunk, eliminating the unnecessary, maybe it is worth it? Javascript is such a mess of a language with it’s tentacles of dependencies. Hence, most operating system distributions will not ship most javascript-based applications (hard to build in build systems where requirement #1 is “no access to the internet”). Repeatability and reduction of dependencies goes a long way towards a more manageable application.

Just a thought. I am not a Javascript developer, so I miss the nuance of these tools. I just rebuild things. :slight_smile: