Npm instances and the general module

Therefore, I use the npm link to develop several modules at the same time, but it causes me problems connecting mongoose, because it does not use the same instance.

If I literally copy my second module to my main node_modules folder, the connections work as expected, the same if I install via github, the problem is that I am linking to npm, the second module has its own instance of using mongoose an existing connection in the main application.

Does anyone know of any workarounds for this?

+4
source share
2 answers

, , , , node node_modules, node_modules, npm mongoose .

, npm node_modules

. ,

|---workspace
      |-----node_modules -> install mongoose or other shared instance modules
      |-----mainApp
               |------node_modules -> delete mongoose or other shared instance modules
      |-----moduleOne
               |------node_modules -> delete mongoose or other shared instance modules
      |-----moduleTwo
               |------node_modules -> delete mongoose or other shared instance modules
+1

Source: https://habr.com/ru/post/1610447/


All Articles