Say you have a project that uses NPM for dependency management. How would you convert that project to use Yarn?
For the longest time the way I did it was just deleting the
package-lock.json and running
yarn to generate a new lockfile. While this works well on small projects, dependency pinning is there for a reason and trying to do this on a larger project may land you in hot water. So how do you do it safely? It's simple:
That's it! When you run
yarn import, yarn will read your
package-lock.json and generate a
yarn.lock file based on it. It's a much safer way to migrate from one package manager to the other.
If you enjoyed this post check out some of my other writing