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

Error regarding BodyParser when upgrading to @nestjs/platform-express 9.3.10 #11302

Closed
3 of 15 tasks
jakobwgnr opened this issue Mar 20, 2023 · 8 comments
Closed
3 of 15 tasks

Comments

@jakobwgnr
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

following error occurs upon build

node_modules/@nestjs/platform-express/adapters/express-adapter.d.ts:46:99 - error TS2694: Namespace 'bodyParser' has no exported member 'BodyParser'.

46     useBodyParser<Options extends bodyparser.Options = bodyparser.Options>(type: keyof bodyparser.BodyParser, rawBody: boolean, options?: NestExpressBodyParserOptions<Options>): this;
                                                                                                     ~~~~~~~~~~
node_modules/@nestjs/platform-express/interfaces/nest-express-application.interface.d.ts:81:101 - error TS2694: Namespace 'bodyParser' has no exported member 'BodyParser'.

81     useBodyParser<Options extends bodyparser.Options = bodyparser.Options>(parser: keyof bodyparser.BodyParser, options?: NestExpressBodyParserOptions<Options>): this;
                                                                                                       ~~~~~~~~~~

Found 2 error(s).

Minimum reproduction code

n/a

Steps to reproduce

nest build

Expected behavior

build should work

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

9.3.10

Packages versions

{
"dependencies": {
    "@azure/storage-blob": "^12.13.0",
    "@drdgvhbh/postgres-error-codes": "0.0.6",
    "@mailchimp/mailchimp_marketing": "^3.0.80",
    "@nestjs/axios": "^2.0.0",
    "@nestjs/common": "^9.3.10",
    "@nestjs/core": "^9.3.10",
    "@nestjs/jwt": "^10.0.2",
    "@nestjs/passport": "^9.0.3",
    "@nestjs/platform-express": "^9.3.10",
    "@nestjs/platform-socket.io": "^9.3.10",
    "@nestjs/swagger": "^6.2.1",
    "@nestjs/typeorm": "^9.0.1",
    "@nestjs/websockets": "^9.3.10",
    "@types/chance": "^1.1.3",
    "@willsoto/nestjs-prometheus": "^5.1.0",
    "base64-stream": "^1.0.0",
    "bcrypt": "^5.1.0",
    "chance": "^1.1.11",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "compression": "^1.7.4",
    "dotenv": "^16.0.3",
    "exceljs": "^4.3.0",
    "express-rate-limit": "^6.7.0",
    "helmet": "^6.0.1",
    "jest-junit": "^15.0.0",
    "lodash": "^4.17.21",
    "morgan": "^1.10.0",
    "multer": "^1.4.4",
    "nest-winston": "^1.9.1",
    "nestjs-paginate": "^7.1.0",
    "passport-azure-ad": "^4.3.4",
    "passport-jwt": "^4.0.1",
    "prom-client": "^14.2.0",
    "reflect-metadata": "^0.1.13",
    "request-context": "^2.0.0",
    "swagger-ui-express": "^4.6.2",
    "typeorm": "0.3.12",
    "uuid": "^9.0.0",
    "winston": "^3.8.2",
    "winston-loki": "^6.0.6"
  }
}

Node.js version

v16.13.2

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@jakobwgnr jakobwgnr added the needs triage This issue has not been looked into label Mar 20, 2023
@kamilmysliwiec
Copy link
Member

Out of curiosity: any specific reason you have the skipLibCheck set to false in your tsconfig.json file?

@jakobwgnr
Copy link
Author

The error didn't occur upon npm start and reverting back to my previous version (9.2.1) resolved the issue

@jakobwgnr
Copy link
Author

@kamilmysliwiec hmm - did not set this option actually... here is my tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "resolveJsonModule": true,
    "noImplicitThis": true,
    "strictBindCallApply": true
  },
  "exclude": ["node_modules", "dist"]
}

@kamilmysliwiec
Copy link
Member

Pardon, I assumed you have it set to false since the base starter project & CLI generated project come with the skipLibCheck set to true. If you set it to true, the error should be gone. Still, we gotta investigate why this issue popped up in the first place. cc @tolgap I think you recently made some changes to that method, could you take a look?

@jakobwgnr
Copy link
Author

Thanks @kamilmysliwiec for the tip - added to my project (Unfortunately I didn't use the starter from Nest back then, but some other from GH...)

@kamilmysliwiec
Copy link
Member

@tolgap I just double-checked and it seems that body-parser lib doesn't ship TS types, so instead we're referencing @types/body-parser package which isn't a required dependency. This breaking change was introduced in this PR #10633

To fix this, we'd have to either duplicate body-parser types in @nestjs/platform-express OR flag @types/body-parser as the required dependency

@tolgap
Copy link
Contributor

tolgap commented Mar 22, 2023

@kamilmysliwiec thanks for the heads up and the investigation 🙏.

I'll work on a fix today!

@micalevisk micalevisk removed the needs triage This issue has not been looked into label Mar 22, 2023
@kamilmysliwiec
Copy link
Member

Let's track this here #11325

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