Build fails with the message, 'Error The "@nestjs/swagger" plugin is not compatible with Nest CLI. Neither "after()" nor "before()" nor "afterDeclarations()" function have been provided.
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current behavior
get an error when trying to build nest app with swagger on it as a plugin but first you need to omit dev-dependencies i saw issue https://github.com/nestjs/nest/issues/9650 and its pretty much the same
his solution was to change the node env to development from production but when we set it to production, the default behavior for npm is to not install dev-dependencies and when we set it to something other then that the dev-dependencies will be install by npm
this is a bug on your part, please fix 😃
Minimum reproduction code
~
Steps to reproduce
- create nest app
- add @nestjs/swagger to package.json witn npm i @nestjs/swagger
- configre nest-cli.json to use @nestjs/swagger plugin
- run npm install --omit=dev // remove dev dependencies from node_modules
- run npx @nestjs/cli start
Expected behavior
build succeed and site is served
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
NestJS version
9.0.3
Packages versions
{
"name": "conf-0.0.1.19",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"scripts": {
"start": "npx -y @nestjs/cli start --tsc --path ./tsconfig.json",
"start:docs": "npx -y @compodoc/compodoc -p tsconfig.json -s -r 8082",
"start:dev": "npx -y @nestjs/cli start --watch --tsc --debug 0.0.0.0:51234 --path ./tsconfig.json",
"start:cloud-env": "npx -y @nestjs/cli start --tsc --path ./tsconfig.build.json",
"docker:database": "docker-compose -p self-schedule-db -f docker/docker-compose.database.yml up -d",
"docker:main": "docker-compose -p self-schedule-main -f ./docker/docker-compose.base.yml -f ./docker/docker-compose.development.yml up",
"docker:main:qa": "docker-compose -p self-schedule-main-qa -f ./docker/docker-compose.qa.yml up",
"docker:dev": "npm run docker:database --force-recreate && npm run docker:main --force-recreate --",
"docker:dev:qa": "npm run docker:database --force-recreate && npm run docker:main:qa --force-recreate --",
"docker:test-explorer": "npm run docker:database && docker run --rm --network self-schedule-db_db-network -v $INIT_CWD:/home/node/server -v $HOME/.vscode-server/extensions:$HOME/.vscode-server/extensions -v $INIT_CWD/docker/db.env:/home/node/server/.env self-schedule-main_server npm run test --",
"test": "DOTENV_CONFIG_PATH=./docker/test.env jest --setupFiles dotenv/config --bail",
"test:watch": "npx -y jest --watch",
"test:cov": "npm t -- --coverage",
"test:debug": "npx -y ts-node-dev --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "npm t -- --config ./test/jest-e2e.json",
"lint": "npx -y eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"format": "npx -y prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"docs": "npx -y @compodoc/compodoc -p tsconfig.json -s -r 8082",
"db:migrate:dev": "npx -y prisma migrate dev",
"db:migrate": "npx -y prisma migrate deploy",
"db:generate": "npx -y prisma generate",
"db:seed": "npx -y prisma db seed",
"db:reset": "npx -y prisma migrate reset"
},
"dependencies": {
"@aws-sdk/client-glue": "^3.110.0",
"@chasdevs/avro-to-typescript": "^1.4.0",
"@fastify/static": "^6.4.0",
"@nestjs/axios": "^0.1.0",
"@nestjs/common": "^9.0.3",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.3",
"@nestjs/event-emitter": "^1.3.0",
"@nestjs/mapped-types": "^1.1.0",
"@nestjs/microservices": "^9.0.3",
"@nestjs/platform-fastify": "^9.0.3",
"@nestjs/schedule": "^2.1.0",
"@nestjs/swagger": "^6.0.3",
"@prisma/client": "^3.11.1",
"avsc": "^5.7.4",
"cache-manager": "^4.0.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"dayjs": "^1.11.2",
"kafkajs": "^2.0.2",
"lodash": "^4.17.21",
"morgan": "^1.10.0",
"morgan-json": "^1.1.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"sql-formatter": "^8.2.0",
"winston": "^3.7.2",
"@types/node": "^16.11.26"
},
"devDependencies": {
"@compodoc/compodoc": "^1.1.19",
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/cache-manager": "^4.0.0",
"@types/cron": "^2.0.0",
"@types/express": "^4.17.13",
"@types/jest": "27.4.1",
"@types/lodash": "^4.14.182",
"@types/morgan": "^1.9.3",
"@types/morgan-json": "^1.1.0",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"prisma": "^3.11.1",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"jest-mock-extended": "^2.0.4",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.7.0",
"ts-node-dev": "^1.1.8",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.6.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node",
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/../src/$1"
}
},
"prisma": {
"seed": "npx -y ts-node prisma/seed.ts"
}
}
Node.js version
16.14
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Build fails with the message, 'Error The "@nestjs/swagger ...
When I run 'npm run build' I am getting the message ' Error The "@nestjs/swagger" plugin is not compatible with Nest CLI. Neither...
Read more >The "@nestjs/swagger" plugin is not compatible with Nest CLI.
Error The "@nestjs/swagger" plugin is not compatible with Nest CLI. Neither "after()" nor "before()" nor "afterDeclarations()" function have been provided.
Read more >How to enable NestJs swagger 4.x plugin - Stack Overflow
It was an issue with global dependencies conflicting with local ones, as well as the old build (set to incremental mode) conflicting with ......
Read more >CLI Plugin - OpenAPI - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines ...
Read more >API with NestJS #60. The OpenAPI specification and Swagger
Swagger is a set of tools built around the OpenAPI specification. The one that we present in this article is the Swagger UI....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
However, by doing some tests, the command that causes the error is the following
npm install --omit=devfollowing the procedure described by @DBTK1990.
in fact not using
npm install --omit=devthe procedure works correctly. (see screenshot) in a local or dev environmentalso using the procedure listed by @micalevisk, the error is not generated ( see screenshot )
in conclusion it occurs to me that the error is generated by an incorrect command procedure, there is an issue like this open in the nest-cli repository see here, waiting for a minimal reproduction, most likely I think it’s a very similar problem to this.
I hope I was helpful
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.