[英]How can I import NeDB as ES Mobule
我需要导入NeDB
并且我需要使用ES Module
来执行此操作,我需要NeDB
的是DataStore
。
当我尝试使用通常的合成器导入DataStore
时:
import { DataStore } from 'nedb';
我有这个错误:
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
我试过了:
import * as nedb from 'nedb';
console.log(nedb)
// Output
// [Function: Datastore]
我也试过:
import nedb from 'nedb';
const { DataStore } = nedb;
console.log(DataStore);
// Output
// undefined
但是我怎样才能访问Datastore
?
谢谢,
马克西姆
我最终找到了解决方案:
import DataStore from 'nedb';
// Then I can use :
new DataStore(...); // works
我不知道我是怎么错过的……谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.