1

We're developing an Electron app with a dependency upon an SDK (that we're also developing). Typically, once the SDK is ready, we do a new release and update the Electron app to use it.

But I'd like to make a local change to the SDK and have the Electron app consume it. This is proving problematic.

The approach I took is to, from the Electron app directory, run

npm install /path/to/sdk/moduleB

i.e. Based on the answers to how to specify local modules as npm package dependencies

However there's a problem. The SDK's sub-modules registers with a core module. i.e. To make an instance available.

When I use a local path to moduleB it cannot find the core module. I don't specify core as a dependency in moduleB. But if I do npm installs a copy under

/path/to/sdk/moduleB/node_modules/core

rather than re-use the module already defined at

./node_modules/core

i.e. Even though they're using the same version.

This behaviour (at least the re-installation of core) makes some sense if you understand how npm resolves the same dependency with different versions.

https://medium.com/learnwithrahul/understanding-npm-dependency-resolution-84a24180901b

and

https://docs.npmjs.com/cli/install

npm install :

Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it’s linked. If sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.

But it seems the install creates a symlink and npm can't search back up into

./node_modules/core

The only way I've been able to work around this is by copying

/path/to/sdk/moduleB

to

./node_modules/moduleB

Is there a better solution that'll allow me to re-use the

./node_modules/core

dependency?

Shane Gannon
  • 6,770
  • 7
  • 41
  • 64

0 Answers0