bluzky/nice-select2

Module not found: Error: Can't resolve 'path' in 'node_modules/nice-select2'

frugan-dev opened this issue ยท 5 comments

Hi, I am using Webpack 5 and I am experiencing this error.
Has anyone tested this library with Webpack 5?

@frugan-it

import NiceSelect from "nice-select2/dist/js/nice-select2";
import "nice-select2/dist/css/nice-select2.css";

try this

@frugan-it

import NiceSelect from "nice-select2/dist/js/nice-select2"; import "nice-select2/dist/css/nice-select2.css";

try this

Thanks! You saved my day

I guess this error is, because the main key in package.json is pointing to webpack.config
https://github.com/bluzky/nice-select2/blob/master/package.json#L5

The main field should point to the entry point of the lib. Normally it is an index.js or something like that.
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#main

I guess this error is, because the main key in package.json is pointing to webpack.config https://github.com/bluzky/nice-select2/blob/master/package.json#L5

The main field should point to the entry point of the lib. Normally it is an index.js or something like that. https://docs.npmjs.com/cli/v8/configuring-npm/package-json#main

Yep, you are right

I still get the same issue even with the "main" key pointing to the js file. The solution to import from the /src directory directly works though. ๐Ÿคท