Accepted answer

With Webpack you can use resolve.alias a long with npm/yarn link in order to have all dependencies use a single instance of React from your host app.

In your development Webpack config add the following:

resolve: {
   alias: {
      react: path.resolve('./node_modules/react'),


The externals in webpack config will be useful.

// webpack.config.js
module.exports = {
  externals: ['react', 'react-dom'],

Normally the react component library does not need to be installed react.


The option I'm currently using on my projects consist of skipping npm/yarn linking at all, and add a NPM script to symlink any local package into node_modules folder like:

  • create an empty node_modules folder
  • run local dependencies linking script
  • install NPM dependencies from root project

If module and the hosting project declares compatible React dependencies you should end up with your local module symlinked and just one React instance installed.

You might also want to automate local dependencies linking with tools like this.

Related Query

More Query from same tag