bluzky / nice-select2

A lightweight vanilla javascript library that replaces native select elements with customizable dropdowns
https://bluzky.github.io/nice-select2/
MIT License
361 stars 60 forks source link

Module not found: Error: Can't resolve 'window' in '/app/node_modules/nice-select2/dist/js' #20

Closed kevinmu17 closed 2 years ago

kevinmu17 commented 2 years ago

Hi, i'm trying out this plugin with webpack.

Trying both of these options and both are not working. import { NiceSelect } from "nice-select2";

import NiceSelect from "nice-select2";

full errorlog:

Compiled with problems:

ERROR in ./node_modules/nice-select2/dist/js/nice-select2.js 1:82-99

Module not found: Error: Can't resolve 'window' in '/app/node_modules/nice-select2/dist/js'

I saw these files where minified so maybe you can take a look at this :)

vinceAmstoutz commented 2 years ago

I have the same problem !

pablomadariaga commented 2 years ago

I have problem. I'm trying compile with webpack. Module not found: Error: Can't resolve 'window'

IIIu6ko commented 2 years ago

+

Tsjippy commented 2 years ago

I cannot solve this problem. I now how js and sccs work but not how webpack and all that work. Waiting for @bluzky

pablomadariaga commented 2 years ago

No puedo resolver este problema. Ahora sé cómo funcionan los js y sccs, pero no cómo funcionan el paquete web y todo eso. Esperando a @bluzky

@bluzky your package is not bad, you should dedicate more time to it and do it in a more professional way, it has great potential and an excellent approach, in addition there are thousands of developers who work with pure JavaScript (vanilla), so you will have a large number of followers.

Basovich commented 2 years ago

A similar error. I was overjoyed early.

hapertown commented 2 years ago

Found a small workaround:

In nice-select2/src/js/nice-select2.js replace export function bind(el, options) to export default function bind(el, options). Next in JS file set:

import NiceSelect from 'nice-select2/src/js/nice-select2.js';
global.NiceSelect = NiceSelect;

and use like: NiceSelect(object, options).

For example: NiceSelect(document.getElementById("a-select"), {searchable: true});