Closed realjesset closed 3 years ago
I'd try "module": "ES2020"
in tsconfig.json
.
There's a very good guide: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
have the same problem.
@oschade please see the guide above
Really wish the ESM only warning were more prominent. This is a massive undertaking for an existing project.
"Use our simple lowdb package! Lightweight! Yay!!!"
Also: "Replace all require()/module.export with import/export."
Just no...
Can't use with coffeescript anymore. Sad!
This made my project no longer run, though this was on me for not doing my due dilligence when updating lowdb to it's next major version.
I got to fix the error and make the imports with js but still have another error
/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:397
throw new ERR_PACKAGE_PATH_NOT_EXPORTED(
^
Error: ERR_PACKAGE_PATH_NOT_EXPORTED /home/mmcs/Templates/lowdb_server/node_modules/lowdb/ ./lib/adapters/JSONFile /home/mmcs/Templates/lowdb_server/node_modules/lowdb/lib/index.js
at throwExportsNotFound (/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:397:9)
at packageExportsResolve (/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:622:3)
at packageResolve (/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:738:14)
at moduleResolve (/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:815:18)
at Object.defaultResolve (/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:929:11)
at /home/mmcs/Templates/lowdb_server/node_modules/ts-node/src/esm.ts:68:38
at Generator.next (<anonymous>)
at /home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist/esm.js:8:71
at new Promise (<anonymous>)
at __awaiter (/home/mmcs/Templates/lowdb_server/node_modules/ts-node/dist/esm.js:4:12)
[nodemon] app crashed - waiting for file changes before starting...
I'm using ts-node with a koa server I did implement the guide above.
Here is my ts.config
{
"compilerOptions": {
"target": "es2017",
"module": "ESNext",
"lib": [
"es6"
] ,
"allowJs": true,
"outDir": "build",
"rootDir": "src" ,
"strict": true ,
"noImplicitAny": true,
"moduleResolution": "node",
"esModuleInterop": true,
/* Advanced Options */
"resolveJsonModule": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
Thanks for the Help!
I am trying this library in TypeScript and I can't find a way to make it work.
I try to import this via
I get the
[ERR_REQUIRE_ESM]: Must use import to load ES Module
error message. I have tried to see all the possible answers but I am failing to understand the main concept.I have changed the module/lib to
ES2020
yet keep facing the same error. Any help is greatly appreciated. I will provide further specifications:I have also added
"type":"module"
inpackage.json
but I see it not working.