bluzky/nice-select2

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

kevinmu17 opened this issue · 7 comments

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 :)

I have the same problem !

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

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

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.

A similar error. I was overjoyed early.

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});