typicode / lowdb

Simple and fast JSON database
MIT License
21.49k stars 923 forks source link

SyntaxError: The requested module 'steno' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export. #490

Closed vijay-pichandi closed 3 years ago

vijay-pichandi commented 3 years ago

I am trying to create lowdb instance and I ran into this issue.

` import low, { JSONFileSync } from 'lowdb'; import { chain } from 'lodash';

const adapter = new JSONFileSync('db.json'); const lowdb = new Low(adapter); db.read(); if (!db.data) { db.data = {}; db.write(); } db.chain = chain(db.data); `

(node:18820) ExperimentalWarning: The ESM module loader is experimental. file:///C:/Spike%20Workspace/NodeJs/project/node_modules/lowdb/lib/esm/adapters/TextFile.js:2 import { Writer } from 'steno'; ^^^^^^ SyntaxError: The requested module 'steno' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export. For example: import pkg from 'steno'; const { Writer } = pkg;

typicode commented 3 years ago

I would try updating Node. Also see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

jslq commented 3 years ago

why not change code to adapter node 12