Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
Swagger UI require fails in Node.js application

I have a Node.js application using Electron v15.3.1. I embed a Swagger UI for viewing OAS files. The Swagger UI version I am using is 4.6.1. It now has a security vulnerability so I need to upgrade it.

I first tried to run npm audit fix which ran successfully, but after that the Swagger UI fails at time when i require it:

let SwaggerUI = require('swagger-ui')

With this error printed in the console of Chrome Dev Tools:

VM67 node:vm:108 Uncaught /Users/benjaminmogensen/workspace/API-JSON-Schema-Definitions/node_modules/react-syntax-highlighter/dist/esm/light.js:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { import highlight from './highlight';
                                                                                                                                                           ^^^^^^

SyntaxError: Cannot use import statement outside a module
    at new Script (node:vm:100:7)
    at createScript (node:vm:257:10)
    at Object.runInThisContext (node:vm:305:10)
    at wrapSafe (node:internal/modules/cjs/loader:1021:15)
    at Module._compile (node:internal/modules/cjs/loader:1066:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1140:10)
    at Module.load (node:internal/modules/cjs/loader:982:32)
    at Module._load (node:internal/modules/cjs/loader:823:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Function.o._load (node:electron/js2c/renderer_init:29:379)

Next, I tried to upgrade to latest version 4.9.0, instead of running npm audit fix. After updating the package.json file and running npm install it's the same result.

I then tried all other versions from 4.6.1 up to 4.9.0 and its the same result. I then tried a previous version - same result.

I have also tried to do a npm cache verify.

However, when I revert to version 4.6.1 and do npm install it works again.

Any help, very much appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This has to do with the electron framework. Unless you have no issue reverting to your old version. I suggest you try this solution.

Babel basically is supposed to bring back the old syntax including stuff such as import

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda