Managing dependencies in AEK 2
With the React16 release of AEK 2, we moved from using NPM to using Yarn. This process was mostly transparent to users, with some issues on new machines on Windows (who hadn’t already installed the AEK CLI with NPM). A lot of the advice in this blog post can apply to dependency management in general, but assume where not stated outright we’re referring to Yarn, and the new React16 release.
The main difference was that instead of a package-lock.json file in your AEK project, you’d find you now had a yarn.lock. These files serve the same purpose – to maintain the specific versions of additional packages required by the AEK (and any development you’re doing). The problem in some cases is that you’ll find yourself with both. Yarn manages this under the hood for you, but it can be confusing to know which files are actually important for your project.
- yarn.lock – you don’t need to do anything with this. Make sure it’s committed with your project, if you’re using source control.
- yarn.lock and package-lock.json – you can delete package-lock; it isn’t necessary anymore.
- package-lock.json – keep this until you next run an
aek install. It’s important in its own right without a yarn.lock present.
My terminal is recommending I upgrade a package
Sometimes you will see messages like this one:
Please ignore it – the AEK framework relies on a specific set of package versions. Running
yarn upgrade will cause Yarn to attempt to upgrade everything to the latest possible version – in some cases beyond the tested compatibility of the versions used in AEK. If you need to upgrade a specific package that you added yourself, please use:
And follow the prompts provided.
How do I add a new package?
aek add package-name
aek acts as a wrapper for the underlying system used. You can append
-dev, or other Yarn options as normal.
My local environment isn’t working correctly – how do I fix this?
Issues with packages upgraded beyond what we’ve tested within the AEK framework can vary dramatically. A recent issue reported was that a user would see an HTTP 405 (Method Not Allowed) in the browser inspector when accessing their local environment. Please follow the steps below to reset your packages to their original state, regardless of the problems that you’re seeing:
- Create a brand-new project with
aek create, following all the prompts provided.
- Copy the yarn.lock this creates over to the project you’re having issues with. You don’t have to back up the old .lock file, but there’s no harm in doing so.
- Delete the node_modules folder.
Warning: this will remove any packages you’ve added yourself. You’ll need to re-add them.