Keeping GatsbyJS Projects Healthy
In this brief post we cover what it takes to keep your GatsbyJS projects up to date and functioning whilst also taking advantages of more recent features.
GatsbyJS (and NodeJS projects for that matter) should have their dependencies updated to their most recent versions at least once a quarter. This gives you the benefit of new feature and bug fixes whilst already protecting yourself from a more difficult update of packages in the future.
To do this I make use of a tool called npm-check that I always install globally in my NodeJS environments as it's handy.
Within your GatsbyJS project install npm-check by running the following:
npm install -g npm-check
Then run the following command to interactively update any packages that might need have to also bumped.
You'll have a long list of upgrades depending on the last time you ran this process. From experience you are okay installing updates from
Minors whereas updates listed under the
Non-Semver you might need to be more careful with.
I have found that most of the time I can take
Non-Semverchanges and not run into issues, but it will depend a lot of what other dependencies you work with.
Go through and install all the updates you would like, then run your normal build/serve commands to test that there are no breaking changes in your site.
# These commands might be slightly different for your build. npm install npm run develop
NOTE: If you have issues running your build after updating, sometimes it can help to clear existing cache by running the two following commands:
# The basic clean gatsby clean # A full clean ONLY do this if the first doesn't work rm -rf node_modules && rm package-lock.json && npm install
Just a short one today, but an important simple process you can run regularly if you get bored and want to update your projects so you aren't falling too far behind.
Please reach out to me on Twitter if you have any further queries or if you have other ways of dealing with this process!