bootstrap-multiselect icon indicating copy to clipboard operation
bootstrap-multiselect copied to clipboard

Module not found: Error: Can't resolve 'knockout' in '~/node_modules/bootstrap-multiselect/dist/js'

Open sourav-prescriber-360 opened this issue 5 years ago • 8 comments

Facing this issue with ^0.9.13-1:

ERROR in ./~/bootstrap-multiselect/dist/js/bootstrap-multiselect.js Module not found: Error: Can't resolve 'knockout' in '/Users/Downloads/projectX/node_modules/bootstrap-multiselect/dist/js' @ ./~/bootstrap-multiselect/dist/js/bootstrap-multiselect.js 51:8-47 @ ./public/javascripts/datatable-gc.js @ ./public/javascripts/speciesTree.js @ ./public/javascripts/render_viewer.js @ multi webpack-hot-middleware/client ./public/javascripts/render_viewer.js

sourav-prescriber-360 avatar Dec 04 '19 07:12 sourav-prescriber-360

Same issue after upgrade to latest version. Any ideas?

7iomka avatar Dec 12 '19 15:12 7iomka

No solution yet, all references are up to date too.

sourav-prescriber-360 avatar Dec 13 '19 03:12 sourav-prescriber-360

I have also had this in conjunction with WARNING in ./node_modules/bootstrap-multiselect/dist/js/bootstrap-multiselect.js 48:48-55 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

I notice in the changelog for this package that some work has been done with regards to using requirejs or require etc, I don't understand it myself as I'm not sure what changes were made and for what purpose. But can see the pattern

@davidstutz - is there any reason why the devDependencies list in package.json on tag 0.9.15 is different to what you get when you download it from NPM? i.e. knockout is not included in the repos package.json anywhere, but when you download it from npm, it has knockout: "*" in there.

adamcopley avatar Jan 08 '20 14:01 adamcopley

any update?

HoiDam avatar Jun 04 '20 05:06 HoiDam

You can try to add these rows to webpack.config.js

plugins: [
  new webpack.ProvidePlugin({
      jQuery: 'jquery',
      'window.jQuery': 'jquery',
  })
],
...
resolve: {
    ...
    alias: {
      // path to your jquery in node_modules
      'jquery': path.resolve(__dirname, 'node_modules/jquery/dist/jquery'),
    }
},
...
module: {
    rules: [
      ...,
      {
        test: require.resolve('bootstrap-multiselect/dist/js/bootstrap-multiselect'),
        use: 'imports-loader?define=>false,this=>window',
      },
      ...
]

it works for me

theory-of-soul avatar Jun 10 '20 15:06 theory-of-soul

Any updates on this one?

theandrewlane avatar Jul 29 '20 16:07 theandrewlane

For Ruby on Rails project with webpacker I had to add this to environment.js to make it work:

environment.loaders.append('this-window', {
  test: /bootstrap-multiselect/,
  use: [
    {
      loader: 'imports-loader',
      options: {
        wrapper: 'window',
        additionalCode: 'var define = false;',
      },
    },
  ],
});

+ yarn add imports-loader. It still shows two warnings on compilation but works.

Lukom avatar Nov 20 '20 12:11 Lukom

I installed bootstrap-multiselect 0.9.15 and I got the error Module not found: Can't resolve 'knockout' in '/Users/aroshasumanaweera/node_modules/bootstrap-multiselect/dist/js. My workaround was to install knockout for the sake of dependency, which worked!!. Run npm i knockout

aroshasum avatar Jan 07 '21 06:01 aroshasum