Skip to content

Cannot run 'nest start' on a path containing '-no-' #3466

Description

@nicolas-spott

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

nest start crashes when the path contains a no segment:

TypeError: Cannot read properties of undefined (reading 'toUpperCase')
    at eval (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/@nestjs+cli@11.0.23_@swc+cli@0.6.0_@swc+core@1.15.41_@types+node@22.19.21_prettier@3.8.4/node_modules/@nestjs/cli/lib/utils/remaining-flags.js#cjs:34:30)
    at Array.reduce (<anonymous>)
    at camelCase (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/@nestjs+cli@11.0.23_@swc+cli@0.6.0_@swc+core@1.15.41_@types+node@22.19.21_prettier@3.8.4/node_modules/@nestjs/cli/lib/utils/remaining-flags.js#cjs:33:28)
    at eval (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/@nestjs+cli@11.0.23_@swc+cli@0.6.0_@swc+core@1.15.41_@types+node@22.19.21_prettier@3.8.4/node_modules/@nestjs/cli/lib/utils/remaining-flags.js#cjs:17:33)
    at Array.filter (<anonymous>)
    at getRemainingFlags (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/@nestjs+cli@11.0.23_@swc+cli@0.6.0_@swc+core@1.15.41_@types+node@22.19.21_prettier@3.8.4/node_modules/@nestjs/cli/lib/utils/remaining-flags.js#cjs:8:10)
    at Command.eval (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/@nestjs+cli@11.0.23_@swc+cli@0.6.0_@swc+core@1.15.41_@types+node@22.19.21_prettier@3.8.4/node_modules/@nestjs/cli/commands/start.command.js#cjs:94:67)
    at Command.listener (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/commander@4.1.1/node_modules/commander/index.js#cjs:370:29)
    at Command.emit (https://nestjstypescriptstartersnkda8s-x1nv.w-credentialless-staticblitz.com/builtins.7045001a.js:30:11034)
    at Command.parseArgs (file:///home/projects/nestjs-typescript-starter-snkda8se/broken-dir-no-broken/node_modules/.pnpm/commander@4.1.1/node_modules/commander/index.js#cjs:892:12)

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-snkda8se?file=.gitignore

Steps to reproduce

  1. cd broken-dir-no-broken
  2. npm i
  3. nest start

Expected behavior

nest start should only strip flag prefixes from actual CLI flags, not from process.argv entries that are file paths.

NestJS version

11.0.1

Packages versions

{
  "name": "nest-typescript-starter",
  "private": true,
  "version": "1.0.0",
  "description": "Nest TypeScript starter repository",
  "license": "MIT",
  "scripts": {
    "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",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "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/jest/bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "engines": {
    "npm": ">=10.0.0",
    "node": ">=20.0.0"
  },
  "dependencies": {
    "@nestjs/common": "^11.0.17",
    "@nestjs/core": "^11.0.1",
    "@nestjs/platform-express": "^11.1.11",
    "reflect-metadata": "^0.2.2",
    "rxjs": "^7.8.1"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3.2.0",
    "@eslint/js": "^9.18.0",
    "@nestjs/cli": "^11.0.0",
    "@nestjs/schematics": "^11.0.0",
    "@nestjs/testing": "^11.0.1",
    "@swc/cli": "^0.6.0",
    "@swc/core": "^1.10.8",
    "@types/express": "^5.0.0",
    "@types/jest": "^29.5.14",
    "@types/node": "^22.10.7",
    "@types/supertest": "^6.0.2",
    "eslint": "^9.18.0",
    "eslint-config-prettier": "^10.0.1",
    "eslint-plugin-prettier": "^5.2.3",
    "globals": "^15.14.0",
    "jest": "^29.7.0",
    "prettier": "^3.4.2",
    "source-map-support": "^0.5.21",
    "supertest": "^7.0.0",
    "ts-jest": "^29.2.5",
    "ts-loader": "^9.5.2",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.7.3",
    "typescript-eslint": "^8.20.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"
  },
  "pnpm": {
    "onlyBuiltDependencies": [
      "@nestjs/core",
      "@swc/core"
    ]
  }
}

Node.js version

20.0.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions