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.41k stars 225 forks source link

DeprecationWarning #277

Closed NawafSwe closed 2 years ago

NawafSwe commented 2 years ago

Issue:

(node:395) [DEP0128] DeprecationWarning: Invalid 'main' field in './lib/index.js'. Please either fix that or report it to the module author

scottie1984 commented 2 years ago

Can you provide more details? Where do you see this message? What is the context - npm install or running your app etc? What versions of node, npm, swagger-ui-express?

sebikeller commented 2 years ago

Hi, I also encounter this error.

When starting my app, which includes this package, the following message is printed:

(node:xxx) [DEP0128] DeprecationWarning: Invalid 'main' field in '[[redacted]/node_modules/swagger-ui-express/package.json]()' of '[./lib/index.js]()'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)

With --trace-deprecation flag:

(node:yyy) [DEP0128] DeprecationWarning: Invalid 'main' field in '[redacted]/node_modules/swagger-ui-express/package.json' of './lib/index.js'. Please either fix that or report it to the module author
    at tryPackage (node:internal/modules/cjs/loader:364:15)
    at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> ([redacted]/dist/debug/[redacted].js:xx:yy)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)

System Information

Import statement: import { serve, setup } from 'swagger-ui-express'; Node version: v16.14.0 NPM version: 8.3.1 Version of swagger-ui-express: 4.0.0

Hope that helps to track this problem for others.

sebikeller commented 2 years ago

Executing npm install swagger-ui-express@4.3.0 fixes the deprecation warning.

Was fixed here: https://github.com/scottie1984/swagger-ui-express/commit/eb63d838e3fa24396ce7216deb4d5130deff0f38 (with v4.0.7 I assume)