typicode / lowdb

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

ES modules is not supported. #467

Closed STDSuperman closed 3 years ago

STDSuperman commented 3 years ago
internal/modules/cjs/loader.js:1080
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\Code\QQRobot\node_modules\lowdb\lib\index.js
require() of ES modules is not supported.
require() of D:\Code\QQRobot\node_modules\lowdb\lib\index.js from D:\Code\QQRobot\dist\main.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\Code\QQRobot\node_modules\lowdb\package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.__decorate (D:\Code\QQRobot\dist\main.js:552:18)
    at __webpack_require__ (D:\Code\QQRobot\dist\main.js:1978:42)
    at Object.<anonymous> (D:\Code\QQRobot\dist\main.js:524:17)
    at __webpack_require__ (D:\Code\QQRobot\dist\main.js:1978:42)
    at Object.<anonymous> (D:\Code\QQRobot\dist\main.js:442:22) {
  code: 'ERR_REQUIRE_ESM'
}