scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.43k stars 227 forks source link

My project is having problems because of assert #362

Open ManoelMorais opened 1 year ago

ManoelMorais commented 1 year ago

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

paulmillr commented 6 months ago

ESM doesn't support JSON.

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

Rajkumar7633 commented 4 months ago

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 commented 3 months ago

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