globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Module not found: Error: Cannot resolve module 'cldr' - in cypress tests #941

Open nensidosari opened 1 year ago

nensidosari commented 1 year ago

I am trying to use one package that contains globalize in our cypress tests, but am failing to use it because of Webpack Compilation Error that shows up.

I am already using this library inside the app, I am only unable to use it within cypress tests. The error that shows up is this when trying to use the library that contains globalize.

Error: Webpack Compilation Error ./node_modules/globalize/dist/globalize.js Module not found: Error: Can't resolve 'cldr' in '/Users/nnn/project/acceptance-tests-cypress/node_modules/globalize/dist' resolve 'cldr' in '/Users/nnn/project/acceptance-tests-cypress/node_modules/globalize/dist' Parsed request is a module using description file: /Users/nnn/project/acceptance-tests-cypress/node_modules/globalize/package.json (relative path: ./dist) Field 'browser' doesn't contain a valid alias configuration resolve as module /Users/nnn/project/acceptance-tests-cypress/node_modules/globalize/dist/node_modules doesn't exist or is not a directory /Users/nnn/project/acceptance-tests-cypress/node_modules/globalize/node_modules doesn't exist or is not a directory .....

All the files being searched exist in node_modules where they are supposed to.

From research, Globalize may not work nicely with Webpack natively, which is the bundler cypress uses. Similar issue to this previously raised https://github.com/globalizejs/globalize/issues/603.

I would appreciate any suggestion on how to resolve this issue.