Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sourav-prescriber-360 opened this issue Dec 4, 2019 · 8 comments

Comments

@sourav-prescriber-360
Copy link

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

@7iomka
Copy link

7iomka commented Dec 12, 2019

Same issue after upgrade to latest version.
Any ideas?

@sourav-prescriber-360
Copy link
Author

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

@adamcopley
Copy link

adamcopley commented Jan 8, 2020

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.

@HoiDam
Copy link

HoiDam commented Jun 4, 2020

any update?

@theory-of-soul
Copy link

theory-of-soul commented Jun 10, 2020

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

@theandrewlane
Copy link

Any updates on this one?

@Lukom
Copy link

Lukom commented Nov 20, 2020

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.

@aroshasum
Copy link

aroshasum commented Jan 7, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants