├── package.json └── packages ├── package-a │ └── package.json # Dependencies: `lodash` └── package-b └── package.json # Dependencies: `lodash`, `package-a`Īfter running npm install, your node_modules folder will look like this. If two of your packages depend on each other, they get the reference from there.įor example, if you have this structure. Your packages (the ones you created) also get symlinked in the root node_modules folder. This is done for performance reasons: if a dependency is shared by multiple packages, it gets saved only once in the root. Now, when you run npm install in a multi-package repository, npm’s dependency tree manager is smart enough to scan your folders looking for all dependencies to install.ĭependencies are hoisted, meaning they get installed in the root node_modules folder. I’ve also provided a repository on GitHub with some sample code from the examples. In this post, you will see how npm Workspaces work, how to get started, and a comparison with other Workspace implementations. This special type of repository is known as a monorepo. In projects like this, you usually have a complex dependency tree, with many packages depending on each other. You can find similarities between all three Workspace implementations.īut what are Workspaces for? Workspaces help us managing repositories with multiple packages - more than one package.json file. In fact, npm is not trying to reinvent the wheel. Other package managers such as Yarn and pnmp already ship with Workspaces for quite a while now. The 7th version of the package manager introduced Workspaces. The newest major release of npm, launched in October 2020, came out with a very anticipated feature (at least for me).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |