adminjs: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\...\Desktop\...\server\node_modules\lodash-es\lodash.js require() of ES modules is not supported.

Contact Details

No response

What happened?

I installed the adminjs and I tried to use it like this:

//Nodejs v14

const AdminJS = require('adminjs')
const express = require('express')

And I got the following message:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\...\Desktop\...\server\node_modules\lodash-es\lodash.js
require() of ES modules is not supported.
require() of C:\Users\...\Desktop\...\server\node_modules\lodash-es\lodash.js from C:\Users\...\Desktop\...\server\node_modules\@tiptap\extension-bubble-menu\dist\index.cjs 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 lodash.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\...\Desktop\...\server\node_modules\lodash-es\package.json.

Please how can I solve this problem?

Bug prevalence

Every time

AdminJS dependencies version

6.8.3

What browsers do you see the problem on?

No response

Relevant log output

No response

Relevant code that’s giving you issues

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 16 (5 by maintainers)

Most upvoted comments

  "main": "index.js",

Version 7+ and it’s compatible packages only work with ESM projects.

6.8.4 solves the issue for me. Thanks!

@dziraf the error has gone away now. Thanks.