Open asieverding opened 4 years ago
Working with angular v12, i am getting the same errors. Any updates on this
Anyone has been able to get through this issue?
The same on my side:
Cannot find module 'vanillajs-datepicker/Datepicker'
or
Cannot find module 'vanillajs-datepicker'
during yarn test
with jest
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
Using jest-node-exports-resolver
fix the issue for me.
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?