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!