Open ManoelMorais opened 1 year ago
ESM doesn't support JSON.
it does, use import with { type: 'json' }
on most recent nodejs
Same issue in import apiDocs from './swagger.json' assert {type: 'json'}; ^^^^^^
SyntaxError: Unexpected identifier 'assert' at compileSourceTextModule (node:internal/modules/esm/utils:337:16) at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:163:18) at callTranslator (node:internal/modules/esm/loader:430:14) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:30) at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)
Node.js v22.2.0
Same issue in import apiDocs from './swagger.json' assert {type: 'json'}; ^^^^^^
SyntaxError: Unexpected identifier 'assert' at compileSourceTextModule (node:internal/modules/esm/utils:337:16) at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:163:18) at callTranslator (node:internal/modules/esm/loader:430:14) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:30) at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)
Node.js v22.2.0
Did you find out what it was , cause now I am having that error , says assert is unexpected identifier, I did everything, also updated my node to latest , but still not working •́ ‿ ,•̀
Update :- Instead of using 'assert' keyword I imported the json file using 'with' and what it worked !|
import serviceAccountKey from './reactjs-blog-website-4f3c2-firebase-adminsdk-o3nwr-6e4413342d.json' with {type: 'json'};
import swaggerDocument from "../swagger.json" assert { type: "json"}; ----------------------------------------------------^^^^^^ Nov 1 11:02:35 AM
Nov 1 11:02:35 AM SyntaxError: Unexpected identifier Nov 1 11:02:35 AM at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18) Nov 1 11:02:35 AM npm ERR! code ELIFECYCLE Nov 1 11:02:35 AM npm ERR! errno 1 Nov 1 11:02:35 AM npm ERR! one@1.0.0 start:
node index
Nov 1 11:02:35 AM npm ERR! Exit status 1