After a bit of digging, I have found a solution in the webpack documentation: npm linked modules doesn’t find their dependencies.
Simply add resolve.fallback
(and resolveLoader.fallback
if your dependencies have loader specific logic, such as using CSS Modules) to your webpack config:
resolve: {
fallback: path.resolve(__dirname, './node_modules')
},
resolveLoader: {
fallback: path.resolve(__dirname, './node_modules')
}
The fallback
setting will make webpack loader look into the local ./node_modules
path for any dependencies that cannot be resolved, including the dependencies of the dependencies of the main app itself. As a result, all peerDependencies
of the main app dependencies will be resolved against the main app ./node_modules
.