Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From npm to Yarn and back again #73

Merged
merged 1 commit into from
Apr 1, 2021

Conversation

svengreb
Copy link
Owner

@svengreb svengreb commented Apr 1, 2021

Resolves #72

Some years ago I switched from npm [1] (`v4`) to Yarn [2] (`v1`) mainly
because of the fantastic workspace feature [3] for monorepos [4] as well
as the great performance and UX improvements. This was a good decision
and almost every popular and well-known project used to do the same,
but with the announcement of Yarn v2 [5] (named "berry" [6]) the
community got upset about the path the project has taken. Next to this,
npm joined GitHub [7] back in March 2020 which meant that the
development continues in a good direction and is baked by the open
source platform itself.
These events, the overall fantastic new npm release version `v7`,
including the introduction of workspaces [8], and the fact that I never
liked the disadvantage of requiring to use an "external" package manager
instead of the one that is bundled with Node, lead to the decision to
finally switch back to npm again.

The only drawback is the constraint that the minimum npm version must be
`v7.7.0` [9] because this is the first version that comes with workspace
support for the `run-script` and `exec` commands through the
`--workspace`/`-w` and `--workspaces`/`-ws` CLI flags,
e.g. `npm run -w PACKAGE run lint`. The first Node version that ships
with npm `v7.7.x` is `v15.13.0` [10] which is globally available as of
April 1, 2021 (no, it's not an april fool).
To ensure that these constraints are met, without only relying on users
to read the documentation, both `npm` and `node` will be added to the
`engines` field [11] of the `package.json` file.

This change also requires updates to all documentations, including the
addition of the version constraints, as well as updates to repository
template features like the GitHub Action workflows.
The `.yarnrc` file will be replaced by `.npmrc` that includes the
`package-lock=false` and `save-exact=false` configurations.

[1]: https://www.npmjs.com
[2]: https://classic.yarnpkg.com
[4]: https://en.wikipedia.org/wiki/Monorepo
[5]: https://yarnpkg.com
[6]: https://github.com/yarnpkg/berry
[7]: https://github.blog/2020-03-16-npm-is-joining-github
[8]: https://docs.npmjs.com/cli/v7/using-npm/workspaces
[9]: https://github.com/npm/cli/releases/tag/v7.7.0
[10]: https://nodejs.org/dist/v15.13.0
[11]: https://docs.npmjs.com/cli/v7/configuring-npm/package-json#engines

GH-72
@svengreb svengreb merged commit b996786 into main Apr 1, 2021
@svengreb svengreb deleted the improvement/gh-72-from-npm-to-yarn-and-back-again branch April 1, 2021 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

From npm to Yarn and back again
2 participants