Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Node 20.9.0 - SyntaxError: Unexpected token 'with' in locale/index.js - adminjs #1683

Open
mjmcgrath2010 opened this issue Jul 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mjmcgrath2010
Copy link

Contact Details

[email protected] / [email protected]

What happened?

SyntaxError: Unexpected token 'with' when upgrading Node to v20.9.0 and [email protected]

I cannot boot my server due to a syntax error stemming from this file:

https://github.com/SoftwareBrothers/adminjs/blob/master/src/locale/index.ts#L3

My tsconfig.json is proper and adheres to documentation, using esm & nodenext, etc..., however, it seems like this forward-looking vision of "ESM is the new future" may hold true, but sadly, it appears that is indeed not the case for with { type: 'json' } syntax sad to report.

Can this be fixed as soon as possible? This package pushes everyone to adhere to ESM, a new and actively changing spec, as opposed to CJS, which has been battle-tested for years with wide support, presumably to be on the "cutting edge of an envisioned future." --- IMO, it is pretty frustrating for an npm package to have control over how I want my modules to be implemented already; the least you can do is ensure that YOUR forward-thinking package adheres to the everchanging ecosystem. Sorry to be blunt, I find this wild.

If we can get this resolved within the next couple of months we'd still be interested in the enterprise version, but if not, it's worth the headache, honestly.

Bug prevalence

Its your bug

AdminJS dependencies version

"@adminjs/design-system": "^4.1.1",
"@adminjs/express": "^6.1.0",
"@adminjs/mongoose": "^4.1.0",
"@adminjs/themes": "^1.0.1",
"adminjs": "^7.8.7",

"typescript": "^5.4.5"

What browsers do you see the problem on?

Firefox, Chrome, Safari, Microsoft Edge

Relevant log output

App [server:1] exited with code [1] via signal [SIGINT]
2024-07-17-13:25:46 PM2                 | App [server:1] starting in -fork mode-
2024-07-17-13:25:46 PM2                 | App [server:1] online
2024-07-17-13:25:46 1|server            | file:///Users/mmcgrath/Development/GrocersList/node_modules/adminjs/lib/locale/index.js:1
2024-07-17-13:25:46 1|server            | import deLocale from './de/translation.json' with { type: 'json' };
2024-07-17-13:25:46 1|server            |                                              ^^^^
2024-07-17-13:25:46 1|server            | SyntaxError: Unexpected token 'with'
2024-07-17-13:25:46 1|server            |     at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:118:18)
2024-07-17-13:25:46 1|server            |     at callTranslator (node:internal/modules/esm/loader:273:14)

Relevant code that's giving you issues

https://github.com/SoftwareBrothers/adminjs/blob/master/src/locale/index.ts#L3

https://github.com/SoftwareBrothers/adminjs/blob/master/package.json#L64 < (not true, please fix)
@mjmcgrath2010 mjmcgrath2010 added the bug Something isn't working label Jul 17, 2024
@dziraf
Copy link
Contributor

dziraf commented Jul 17, 2024

In Node 20.10.0 the import syntax's changed from import ... assert to import ... with. You can either upgrade Node to 20.10.0 or downgrade adminjs to 7.8.1.

Do note that the current LTS version is 20.15.1. I'll update package.json to explicitly say that node version must be greater or equal 20.10.0.

While I agree that Node's implementation of ESM is not the best, we'd been forced to migrate ourselves due to our dependencies abandoning CJS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants