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

My project is having problems because of assert #362

Open
ManoelMorais opened this issue Nov 1, 2023 · 3 comments
Open

My project is having problems because of assert #362

ManoelMorais opened this issue Nov 1, 2023 · 3 comments

Comments

@ManoelMorais
Copy link

ManoelMorais commented Nov 1, 2023

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

@ManoelMorais ManoelMorais changed the title User the Importtttttttttttttttttttttttttttttt please, My project is having issues because I'm using 'import' instead of 'const require.' Please update that My project is having problems because of assert Nov 4, 2023
@paulmillr
Copy link

ESM doesn't support JSON.

it does, use import with { type: 'json' } on most recent nodejs

@Rajkumar7633
Copy link

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

@rajrasane04
Copy link

rajrasane04 commented Jul 14, 2024

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'};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants