Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript ESM import error #326

Open
matrm opened this issue Feb 7, 2025 · 0 comments
Open

Typescript ESM import error #326

matrm opened this issue Feb 7, 2025 · 0 comments

Comments

@matrm
Copy link

matrm commented Feb 7, 2025

Error message:

node_modules/lmdb/index.d.ts:470:1 - error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.

470 export = lmdb

The error message goes away and it is possible to compile without errors when manually changing the last line of index.d.ts from
export = lmdb
to
export default lmdb

testing code:

import lmdb from 'lmdb';

let myDB = lmdb.open({
	path: 'my-db'
});
await myDB.put('greeting', { someText: 'Hello, World!' });
myDB.get('greeting').someText // 'Hello, World!'
// or
myDB.transaction(() => {
	myDB.put('greeting', { someText: 'Hello, World!' });
	myDB.get('greeting').someText // 'Hello, World!'
});

tsconfig.json:

{
	"compilerOptions": {
		"moduleResolution": "NodeNext",
		"target": "ESNext",
		"module": "NodeNext",
		"outDir": "./dist"
	},
	"include": [
		"src/**/*"
	],
	"exclude": [
		"./node_modules"
	]
}

package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "test",
  "type": "module",
  "scripts": {
    "build": "tsc",
    "start": "npm run build && node dist/index.js"
  },
  "dependencies": {
    "@types/node": "^22.13.1",
    "lmdb": "^3.2.5"
  },
  "devDependencies": {
    "typescript": "^5.7.3"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant