question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Avoid loading linked modules multiple times

See original GitHub issue

We run into the following issue with quite a large dependency tree:

When linking packages with npm link that share a dependency, Browserify loads the module twice because they are in different paths. This leads to various problems from multiple socket connections to instanceof not working anymore.

It would be great if Browserify could consider the package.json’s name / version to detect this case.

Thanks!

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
ericsococommented, Apr 6, 2016

Finally found a reusable solution to the problem of duplicated deps when npm linking, and it’s not specific to any build tool: http://stackoverflow.com/a/36464203/222356

In short, remove secondary dependencies from the npm linked module, add your downstream project’s node_modules to NODE_PATH, and resolve secondary dependencies in your downstream project.

e.g. NODE_PATH=$(pwd)/node_modules/ npm start

Curious to hear your thoughts.

0reactions
oztunecommented, May 18, 2016

I found the solution @ericsoco suggested to work perfectly without requiring any project changes.

For future readers, to make this fit into our existing workflow I put together a node module you may find useful and save you some keystrokes: https://github.com/oztune/gn

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize Angular lazy loading modules for multiple frontends
In this article, we will explore how to build an Angular app with multiple frontends by utilizing lazy loading feature modules and dynamic ......
Read more >
Common modularization patterns - Android Developers
This page gives an overview of some general rules and common patterns that you can employ when developing multi module Android apps.
Read more >
What Happens When a Module Is Imported Twice?
A JavaScript module is evaluated just once. When imported multiple times from the same path, the same module instance is returned.
Read more >
Lazy Loading Angular Modules and Preloading Strategies
It loads only the components that are required to render the page. This saves time and renders the application much faster than eager...
Read more >
Duplicated Vue runtime while loading vue library modules ...
You will need two Vue projects, one will need be a library, the other a standard Vue project. ... This indicates more than...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found