![]() The sample_one is the main package that imports this module and uses this in its React app. The sample_counter is a module that implements the cliched React component that increments a counter on button click. The monorepo contains two packages viz., sample_one and sample_counter. To demonstrate this, I have created the following monorepo. This may not be a problem but libraries like React throw an error when there are duplicates. In effect, the node_modules directory of our main package will have two copies of library A. In addition, the node_modules directory of our module which is referenced to from within the node_modules directory of our main package will also have library A. The node_modules directory of our main package will already have a copy of library A. Say, we use a library called A in both the module and our main package. This may not usually cause problems but certain libraries don’t take kindly to having multiple copies of it in the node_modules directory. ![]() However, since Lerna creates a symlink of your dependency package, which we shall refer to as a module henceforth, the node_modules directory of your module also gets referred to from your main package’s node_modules folder. Lerna accomplishes this by creating a symlink of your dependency inside your main package’s node_modules folder. Have a package that is a dependency of another and you don’t want to waste time building the dependency, publishing it to npm, and then installing it into your package? Then, Lerna can get behind the wheel for you and let you use your dependency package within your main package by completely eliminating the need to publish it. Lerna comes to our rescue when we are to manage multiple inter-dependent packages within a repository. ![]() Give us your email address and whenever I write something, you'll receive a little email in your inbox.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |