mymth / vanillajs-datepicker

A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks
MIT License
756 stars 155 forks source link

Cannot find module #26

Open asieverding opened 4 years ago

asieverding commented 4 years ago

I'm using webpack for bundling with hot reloading. When I put import { Datepicker } from 'vanillajs-datepicker' in my code at runtime (with hot reload), the datepicker is working awesome and without any errors. But when I want to stop and restart my webapp, then I get the following error: Error: Cannot find module 'vanillajs-datepicker'

When I use import Datepicker from 'path/to/node_modules/vanillajs-datepicker/js/Datepicker.js' I get the same behavior but a different error message: ReferenceError: EventTarget is not defined

Do you now anything about that?

alaksandarjesus commented 2 years ago

Working with angular v12, i am getting the same errors. Any updates on this

softhedev commented 2 years ago

Anyone has been able to get through this issue?

BartusZak commented 2 years ago

The same on my side:

Cannot find module 'vanillajs-datepicker/Datepicker'

or

Cannot find module 'vanillajs-datepicker'

during yarn test with jest

JoshMayberry commented 2 years ago

I had this same issue. For me, modifying the package.json's export area to the following fixed it for me (I added the redundant paths at the end):

"exports": {
    ".": "./js/main.js",
    "./Datepicker": "./js/Datepicker.js",
    "./DateRangePicker": "./js/DateRangePicker.js",
    "./locales/*": "./js/i18n/locales/*.js",
    "./locales/": "./js/i18n/locales/",

    "./js/main.js": "./js/main.js",
    "./js/Datepicker.js": "./js/Datepicker.js",
    "./js/DateRangePicker.js": "./js/DateRangePicker.js",
    "./js/i18n/locales/*.js": "./js/i18n/locales/*.js",
    "./js/i18n/locales/": "./js/i18n/locales/"
  },

I can then do the following import Datepicker from "vanillajs-datepicker/js/Datepicker.js"; and not get the error Package path ./js/Datepicker.js is not exported from package that would show up if I tried importing it this way

mmouterde commented 1 year ago

Using jest-node-exports-resolver fix the issue for me.