Tech Blog

NPM and Yarn with AEK 2

This post will outline some quick dos and don’ts on how best to handle issues in adding or removing new packages in AEK 2.

In our most recent release of AEK 2, we moved from using NPM under the hood, to Yarn. When adding a package before, you’d have used npm install package-name --save in order to get the package added to your project’s package.json. In Yarn, it’s simpler; yarn add package-name.  For other options (including devDependencies), check out the documentation.

The AEK command line has commands that match the available Yarn commands; we recommend this though it’s not strictly necessary. For example, aek add package-name. We definitely do not recommend doing npm related commands anymore – these may still work for users that have NPM installed globally on their machines, but it will interact poorly with the state of the project as installed by Yarn.

Any install, or adding of packages, will trigger a varying amount of warnings. There isn’t a problem with this. AEK is a framework, maintained by campusM. We use specific versions of certain packages, and we have to keep their corresponding dependencies at certain versions as well.

Updating a specific package

We don’t recommend doing a blanket yarn or aek upgrade(previously update, under NPM), as Yarn will try to update all dependencies to their latest possible versions. This can cause problems as the AEK relies on specific versions (sometimes within a tested acceptable range of available versions).

We recommend using aek upgrade-interactive to selectively update each dependency, or just aek upgrade my-specific-package. The boilerplate comes with a yarn.lock file that contains locked versions of the dependencies that we know work together and we can’t confidently guarantee perfect results if there is any movement from that lock file.

Updating aek-lib

If you want the latest aek-lib, upgrade is also not the best tool – we recommend you upgrade the aek-lib package specifically with with aek add @ombiel/aek-lib@latest.

Leave a Reply