nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.87k stars 7.55k forks source link

Swagger plugin breaks Heroku and Render builds #10055

Closed danilloism closed 2 years ago

danilloism commented 2 years ago

Is there an existing issue for this?

Current behavior

I have the swagger plugin enabled in my project and If i run the build command locally it completes without any problem, but when i try to deploy to both Heroku and Render i get this error from the plugin when the build command is triggered:

Heroku: On Heroku, this is the command in Procfile:

web: pnpm run start:prod

Output log:

Build
       Running build

       > laboratorio_ferreira_api@0.0.1 prebuild
       > rimraf dist

       > laboratorio_ferreira_api@0.0.1 build
       > nest build

        Error  The "@nestjs/swagger" plugin is not compatible with Nest CLI. Neither "after()" nor "before()" nor "afterDeclarations()" function have been provided.

-----> Build failed

       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys

       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/

       Love,
       Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed

Render: On Render, I did the following setup for build and run: Build command:

pnpm install --frozen-lockfile; pnpm prebuild; npx prisma generate; npx prisma migrate deploy; pnpm build;

Start command:

pnpm start:prod

Output log:

Aug 1 10:24:28 AM  > laboratorio_ferreira_api@0.0.1 build /opt/render/project/src
Aug 1 10:24:28 AM  > nest build
Aug 1 10:24:28 AM  
Aug 1 10:24:37 AM  
Aug 1 10:24:37 AM   Error  The "@nestjs/swagger" plugin is not compatible with Nest CLI. Neither "after()" nor "before()" nor "afterDeclarations()" function have been provided.
Aug 1 10:24:37 AM  
Aug 1 10:24:37 AM   ELIFECYCLE  Command failed with exit code 1.
Aug 1 10:24:37 AM  ==> Build failed 😞

It appears that it isnt a Heroku or Render problem, since they are different services and reproduce the same error.

Minimum reproduction code

https://github.com/danilloism/laboratorio_ferreira_api

Steps to reproduce

No response

Expected behavior

The build it's successful just like when its run locally.

Package

Other package

@nest/cli @nest/swagger

NestJS version

9.0.7

Packages versions

{
  "name": "laboratorio_ferreira_api",
  "version": "0.0.1",
  "description": "API RESTful do sistema Laboratório de Prótese Dentária Ferreira.",
  "author": "Danillo Ilggner <danilloilggner@gmail.com>",
  "license": "MIT",
  "scripts": {
    "preinstall": "npx only-allow pnpm",
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "db:migrate:dev": "prisma migrate dev",
    "db:gen": "prisma generate",
    "db": "pnpm db:migrate:dev && pnpm db:gen",
    "db:studio": "prisma studio",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest --verbose",
    "test:watch": "jest --watch",
    "test:cov": "pnpm test --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@faker-js/faker": "^7.3.0",
    "@nestjs/axios": "^0.1.0",
    "@nestjs/cli": "^9.0.0",
    "@nestjs/common": "^9.0.7",
    "@nestjs/config": "^2.2.0",
    "@nestjs/core": "^9.0.7",
    "@nestjs/jwt": "^9.0.0",
    "@nestjs/mapped-types": "^1.1.0",
    "@nestjs/passport": "^9.0.0",
    "@nestjs/platform-express": "^9.0.7",
    "@nestjs/swagger": "^6.0.4",
    "@nestjs/terminus": "^9.1.0",
    "@prisma/client": "^4.1.1",
    "bcrypt": "^5.0.1",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.13.2",
    "compression": "^1.7.4",
    "currency.js": "^2.0.4",
    "express": "^4.18.1",
    "helmet": "^5.1.1",
    "jest": "^28.1.3",
    "nest-winston": "^1.7.0",
    "newrelic": "^8.17.0",
    "passport": "^0.6.0",
    "passport-http-bearer": "^1.0.1",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "pnpm": "^7.8.0",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.5.6",
    "uuid": "^8.3.2",
    "winston": "^3.8.1"
  },
  "devDependencies": {
    "@nestjs/schematics": "^9.0.1",
    "@nestjs/testing": "^9.0.7",
    "@types/bcrypt": "^5.0.0",
    "@types/compression": "^1.7.2",
    "@types/express": "^4.17.13",
    "@types/jest": "^28.1.6",
    "@types/node": "^18.6.3",
    "@types/passport-jwt": "^3.0.6",
    "@types/passport-local": "^1.0.34",
    "@types/supertest": "^2.0.12",
    "@types/uuid": "^8.3.4",
    "@typescript-eslint/eslint-plugin": "^5.31.0",
    "@typescript-eslint/parser": "^5.31.0",
    "eslint": "^8.21.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-prettier": "^4.2.1",
    "prettier": "^2.7.1",
    "prisma": "^4.1.1",
    "source-map-support": "^0.5.21",
    "supertest": "^6.2.4",
    "ts-jest": "^28.0.7",
    "ts-loader": "^9.3.1",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.0.0",
    "typescript": "^4.7.4",
    "webpack": "^5.74.0"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  },
  "eslintIgnore": [
    ".eslintrc",
    "node_modules",
    "dist",
    "coverage"
  ],
  "engines": {
    "node": "18"
  }
}

Node.js version

18.5.0

In which operating systems have you tested?

Other

Related issues:

9650 #9429

kamilmysliwiec commented 2 years ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.