environment:
In nestjs project's package.json
"date-holidays": "3.14.4"
"@nestjs/core": "7.6.12",
...
holiday.service.ts
import Holidays from "date-holidays";
getHolidays() {
const holidays = new Holidays();
}
when i run project, i get error
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /media/ryan/home/work/sources/ryan-test-project/node_modules/astronomia/data/vsop87Bearth.js
require() of ES modules is not supported
require() of /media/media/ryan/home/work/sources/ryan-test-project/node_modules/astronomia/data/vsop87Bearth.js from /media/media/ryan/home/work/sources/ryan-test-project/node_modules/date-holidays-parser/lib/vsop87Bearth.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename vsop87Bearth.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /media/media/ryan/home/work/sources/ryan-test-project/node_modules/astronomia/package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1174:13)
......
environment: In nestjs project's package.json "date-holidays": "3.14.4" "@nestjs/core": "7.6.12", ...
holiday.service.ts import Holidays from "date-holidays";
getHolidays() { const holidays = new Holidays(); }
when i run project, i get error Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /media/ryan/home/work/sources/ryan-test-project/node_modules/astronomia/data/vsop87Bearth.js require() of ES modules is not supported require() of /media/media/ryan/home/work/sources/ryan-test-project/node_modules/astronomia/data/vsop87Bearth.js from /media/media/ryan/home/work/sources/ryan-test-project/node_modules/date-holidays-parser/lib/vsop87Bearth.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename vsop87Bearth.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /media/media/ryan/home/work/sources/ryan-test-project/node_modules/astronomia/package.json. at Object.Module._extensions..js (internal/modules/cjs/loader.js:1174:13) ......
Can I how to resolve the problem?