Migrating From Yarn to npm

A guide on how to switch from Yarn to npm for dependency management

There’s probably multiple articles of this sort online. But I’m going to be doing these same steps for a few of my projects so I figured I might as well make a post about it 🦀

This guide covers how to switch from Yarn to npm to manage dependencies for a project. This guide assumes a non-complex setup (eg: no monorepos). This guide will not cover migrating away from specific features such as Yarn workspaces.

To switch from Yarn to npm run the following steps in your project’s folder:

  1. Remove yarn.lock as this file will no longer be used.
  2. Run npm install. This will generate a package-lock.json file.
  3. Use git grep yarn to find any remaining references to yarn. Replace these references either with an equivalent from npm cli or other command as appropriate.
  4. Try running and building your application to confirm that it still works.

Here’s some other things that you may need to check:

Built with Hugo
Theme Stack designed by Jimmy