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

nestjs/platform-express@11.0.2 missing path-to-regexp #14461

Closed
3 of 15 tasks
Alsdrouf opened this issue Jan 20, 2025 · 3 comments
Closed
3 of 15 tasks

nestjs/platform-express@11.0.2 missing path-to-regexp #14461

Alsdrouf opened this issue Jan 20, 2025 · 3 comments
Labels
needs triage This issue has not been looked into

Comments

@Alsdrouf
Copy link

Alsdrouf commented Jan 20, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I may be wrong but it seems that when upgrading to @nestjs/platform-express@11.0.2 there's an error you may see my PR for nestjs-paginate

Using createNestApplication from a testing module without new ExpressAdapater() in it create an error like if @nestjs/platform-express wasn't installed
With new ExpressAdapter() it create an error Cannot find module 'path-to-regexp'

PR: ppetzold/nestjs-paginate#1041
CI: https://github.com/ppetzold/nestjs-paginate/actions/runs/12866208472/job/35868297365?pr=1041

Minimum reproduction code

https://github.com/Alsdrouf/nestjs-paginate/tree/feat/updateNestjsToV11

Steps to reproduce

  1. npm i
  2. npm run test pagination-docs.spec.ts

Expected behavior

No error, or not this kind of error

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

11.0.2

Packages versions

{
  "name": "nestjs-paginate",
  "version": "0.1.0",
  "author": "Philipp Petzold <ppetzold@protonmail.com>",
  "license": "MIT",
  "main": "lib/index.js",
  "typings": "lib/index.d.ts",
  "files": [
    "lib/**/*"
  ],
  "description": "Pagination and filtering helper method for TypeORM repositories or query builders using Nest.js framework.",
  "keywords": [
    "nestjs",
    "typeorm",
    "express",
    "pagination",
    "paginate",
    "filtering",
    "search"
  ],
  "scripts": {
    "prebuild": "rimraf lib",
    "build": "tsc",
    "prepare": "tsc",
    "dev:yalc": "nodemon --watch src --ext ts --exec 'npm run build && yalc push'",
    "format": "prettier --write \"src/**/*.ts\"",
    "format:ci": "prettier --list-different \"src/**/*.ts\"",
    "lint": "eslint -c .eslintrc.json --ext .ts --max-warnings 0 src",
    "test": "jest",
    "test:watch": "jest --watch ",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
  },
  "devDependencies": {
    "@nestjs/common": "^11.0.2",
    "@nestjs/platform-express": "^11.0.2",
    "@nestjs/testing": "^11.0.2",
    "@types/express": "^5.0.0",
    "@types/jest": "^29.5.14",
    "@types/lodash": "^4.17.14",
    "@types/node": "^22.10.5",
    "@typescript-eslint/eslint-plugin": "^7.18.0",
    "@typescript-eslint/parser": "^7.18.0",
    "dotenv": "^16.4.7",
    "eslint": "^8.57.1",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "fastify": "^5.2.1",
    "jest": "^29.7.0",
    "mysql": "^2.18.1",
    "pg": "^8.13.1",
    "prettier": "^3.0.3",
    "reflect-metadata": "^0.1.14",
    "rxjs": "^7.8.1",
    "sqlite3": "^5.1.7",
    "ts-jest": "^29.2.5",
    "ts-node": "^10.9.2",
    "typeorm": "^0.3.17",
    "typescript": "^5.5.4"
  },
  "dependencies": {
    "lodash": "^4.17.21"
  },
  "peerDependencies": {
    "@nestjs/common": "^11.0.2",
    "@nestjs/swagger": "^11.0.2",
    "express": "^5.0.1",
    "fastify": "^5.2.1",
    "typeorm": "^0.3.17"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".spec.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "coverageDirectory": "../coverage",
    "testEnvironment": "node",
    "setupFiles": [
      "<rootDir>/../jest.setup.ts"
    ]
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ppetzold/nestjs-paginate.git"
  },
  "homepage": "https://github.com/ppetzold/nestjs-paginate#readme",
  "bugs": {
    "url": "https://github.com/ppetzold/nestjs-paginate/issues"
  },
  "publishConfig": {
    "access": "public"
  },
  "release": {
    "branches": [
      "master"
    ]
  }
}

Node.js version

11.0.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

 FAIL  src/swagger/pagination-docs.spec.ts
  ● Test suite failed to run
                                                                                                                                                                                    
    Cannot find module 'path-to-regexp' from '../node_modules/@nestjs/platform-express/adapters/express-adapter.js'

    Require stack:
      /home/leichhorn/dev/nestjs-paginate/node_modules/@nestjs/platform-express/adapters/express-adapter.js
      /home/leichhorn/dev/nestjs-paginate/node_modules/@nestjs/platform-express/adapters/index.js
      /home/leichhorn/dev/nestjs-paginate/node_modules/@nestjs/platform-express/index.js
      swagger/pagination-docs.spec.ts

       6 | import { ApiPaginationQuery } from './api-paginated-query.decorator'
       7 | import { ApiOkPaginatedResponse } from './api-ok-paginated-response.decorator'
    >  8 | import { ExpressAdapter } from '@nestjs/platform-express'
         | ^
       9 |
      10 | const BASE_PAGINATION_CONFIG = {
      11 |     sortableColumns: ['id'],

      at Resolver._throwModNotFoundError (../node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (../node_modules/@nestjs/platform-express/adapters/express-adapter.js:13:26)
      at Object.<anonymous> (../node_modules/@nestjs/platform-express/adapters/index.js:4:22)
      at Object.<anonymous> (../node_modules/@nestjs/platform-express/index.js:10:22)
      at Object.<anonymous> (swagger/pagination-docs.spec.ts:8:1)
@Alsdrouf Alsdrouf added the needs triage This issue has not been looked into label Jan 20, 2025
@kamilmysliwiec
Copy link
Member

Fixed 5eaae5f and published as 11.0.3

@FradiFrad
Copy link

I have a similar issue while running nest start, using "@nestjs/platform-express": "^11.0.6"

Error: Cannot find module 'router'
Require stack:

- node_modules/express/lib/application.js
- node_modules/express/lib/express.js
- node_modules/express/index.js
- node_modules/@nestjs/platform-express/adapters/express-adapter.js
- node_modules/@nestjs/platform-express/adapters/index.js
- node_modules/@nestjs/platform-express/index.js

@micalevisk
Copy link
Member

@FradiFrad run npm ls router

Image


Please provide a minimum reproduction repository. You can start one by running npm init nest in your terminal

why reproductions are required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

4 participants