I am currently developing a plugin that relies on jQuery as a peer dependency. However, when I attempt to import this plugin into my primary project (which already has jQuery installed), I encounter the following error:
Module not found: Error: Can't resolve 'jquery' in <(plugin's folder)>
. It appears that webpack is searching for jQuery in the plugin's node_modules folder instead of the root project's node_modules folder when dynamically importing the peer dependency. Is there a way to configure webpack to search in the root project's node_modules directory rather than the plugin's?
Here is my Webpack configuration file ('Webpack.config.js'):
var webpack = require('webpack');
module.exports = {
entry: './main.js',
output: {
filename: 'bundle.js'
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
watch: true,
resolve: {
alias: { jquery: "jQuery" }
}
};