[英]How can I import NeDB as ES Mobule
I need to import NeDB
and I need to do this using ES Module
, what I need from NeDB
is DataStore
.我需要导入
NeDB
并且我需要使用ES Module
来执行此操作,我需要NeDB
的是DataStore
。
When I try to import DataStore
using the usual synthax:当我尝试使用通常的合成器导入
DataStore
时:
import { DataStore } from 'nedb';
I have this error:我有这个错误:
Named export 'Datastore' not found. The requested module 'nedb' is a CommonJS module,
which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export
I tried:我试过了:
import * as nedb from 'nedb';
console.log(nedb)
// Output
// [Function: Datastore]
I also tried:我也试过:
import nedb from 'nedb';
const { DataStore } = nedb;
console.log(DataStore);
// Output
// undefined
But how can I access Datastore
?但是我怎样才能访问
Datastore
?
Thx,谢谢,
Maxime马克西姆
I finnaly foud the solution:我最终找到了解决方案:
import DataStore from 'nedb';
// Then I can use :
new DataStore(...); // works
I don't know how I missed it... Thx everyone我不知道我是怎么错过的……谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.