adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

[Bug]: Can't import package

Open Neil-Brown opened this issue 2 years ago • 8 comments

Contact Details

No response

What happened?

I have installed the following packages @adminjs/express: ^6.0.0, @adminjs/mongoose: 4.0.0, and adminjs: ^7.0.0. In my app.js file I am importing them as per the docs as follows:

import AdminJS from 'adminjs'
import * as AdminJSExpress from '@adminjs/express'

But when I run the app I get the following error:

file:///C:/Users/USER01/github/express-template/node_modules/adminjs/lib/locale/index.js:1
import deLocale from './de/translation.json' assert { type: 'json' };
                                             ^^^^^^

SyntaxError: Unexpected identifier
    at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)

My node version is v14.17.3

Bug prevalence

Whenever I run the app

AdminJS dependencies version

"dependencies": {
    "@adminjs/express": "^6.0.0",
    "@adminjs/mongoose": "^4.0.0",
    "adminjs": "^7.0.0",
    "compression": "^1.7.4",
    "express": "^4.18.2",
    "express-formidable": "^1.2.0",
    "express-session": "^1.17.3",
    "helmet": "^6.1.5",
    "pug": "^3.0.2",
    "serve-favicon": "^2.5.0",
    "tslib": "^2.5.0"
  }

What browsers do you see the problem on?

Chrome

Relevant log output

file:///C:/Users/USER01/github/express-template/node_modules/adminjs/lib/locale/index.js:1
import deLocale from './de/translation.json' assert { type: 'json' };
                                             ^^^^^^

SyntaxError: Unexpected identifier
    at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)

Relevant code that's giving you issues

import AdminJS from 'adminjs'
import * as AdminJSExpress from '@adminjs/express'

Neil-Brown avatar Apr 20 '23 03:04 Neil-Brown

Please update NodeJS to LTS (v18)

dziraf avatar Apr 20 '23 08:04 dziraf

the error continue, same installing the nodeJS v18

andersonszdc avatar May 01 '23 12:05 andersonszdc

getting this error please help

rccoding avatar Jun 08 '23 11:06 rccoding

I stopped getting this error using node v20

nachomglz avatar Jul 16 '24 12:07 nachomglz