I have two projects. Let's say: Project A, Project B Project B is a dependent module in Project A
When we do npm start i.e. start the server for Project A, the nconf gets initialized with development env files succesfully and returns all the related env variables without any error.
For project B it also uses nconf for some of its module.
Now when I am normally installing the dependecies of Project A from npm install command, Project B gets installed but duplicate dependencies gets removed. And because of this when using any reference to nconf in Project B it uses the one present in Project A.
Since I am doing local dev I don't want to publish the Project B everytime I make some changes and thus came to know about npm link where we can create a symlink for the local packages.
But when I am creating a symlink for Project B in Project A. The duplicate dependencies are not getting removed from Project B node_modules as they were getting removed while doing npm install. And thus when Project A invokes any module of Project B which uses nconf, it does not finds the env files and thus returns undefined.
Things I've tried:
- Using npm dedup on Project A to delete any duplicate dependencies, but instead of deleting the duplicate dependencies it is also removing the linked packages and is installing the published ones and therefore I can't test the local changes.
- Deleting node_modules from Project B and then linking it to Project A, but now it says that nconf was not provided.
- Using file based dependency load i.e, in dependencies object of Project A: { projectB: "file:../projectB" }. But again it is having the same issue.
I am expecting to npm link in the similar way as it does while doing npm install, or a way that Project B's nconf uses project A's initialized nconf file path.
Note: Both uses same version of nconf