Nest.js - "Invalid command: start"

Nest.js - "Invalid command: start"

此应用在 docker 容器中运行了很长时间,最近甚至无法启动。

在 docker 容器中出现此错误:

app  | > app@0.0.1 start:debug /srv/app
app  | > nest start --debug 127.0.0.1:9229 --watch
app  | 
app  | Invalid command: start
app  | See --help for a list of available commands.
app  | npm ERR! code ELIFECYCLE
app  | npm ERR! errno 1
app  | npm ERR! app@0.0.1 start:debug: `nest start --debug 127.0.0.1:9229 --watch`
app  | npm ERR! Exit status 1
app  | npm ERR! 
app  | npm ERR! Failed at the app@0.0.1 start:debug script.
app  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
app  | 
app  | npm ERR! A complete log of this run can be found in:
app  | npm ERR!     /root/.npm/_logs/2022-04-07T13_01_07_426Z-debug.log

如果我通过我机器上的终端启动它,它就不会启动而不会出现任何错误:

/develop/app -> npm run start     (06:57:32 PM)

> app@0.0.1 start
> nest start



/develop/app ->.                  (06:57:39 PM)

我的package.json:

{
  "name": "app",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:docker": "docker-compose up --build -V",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug 127.0.0.1:9229 --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/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@hapi/joi": "^17.1.1",
    "@nestjs/common": "^8.0.0",
    "@nestjs/config": "^1.0.1",
    "@nestjs/core": "^8.0.6",
    "@nestjs/microservices": "^8.0.11",
    "@nestjs/platform-express": "^8.0.0",
    "@nestjs/serve-static": "^2.2.2",
    "@nestjs/swagger": "^5.0.9",
    "@nestjs/typeorm": "^8.0.2",
    "class-transformer": "^0.4.0",
    "class-validator": "^0.13.1",
    "dotenv": "^10.0.0",
    "joi": "^17.4.2",
    "kafkajs": "^1.15.0",
    "libphonenumber-js": "^1.9.38",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.3.0",
    "swagger-ui-express": "^4.1.6",
    "ua-parser-js": "^1.0.2",
    "xlsx": "^0.18.5"
  },
  "devDependencies": {
    "@nestjs/cli": "^5.6.2",
    "@nestjs/schematics": "^8.0.0",
    "@nestjs/testing": "^8.0.0",
    "@types/convert-excel-to-json": "^1.7.1",
    "@types/express": "^4.17.13",
    "@types/jest": "^27.0.1",
    "@types/multer": "^1.4.7",
    "@types/node": "^14.14.31",
    "@types/supertest": "^2.0.10",
    "@types/ua-parser-js": "^0.7.36",
    "@typescript-eslint/eslint-plugin": "^4.15.2",
    "@typescript-eslint/parser": "^4.15.2",
    "eslint": "^7.20.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-prettier": "^3.3.1",
    "jest": "^27.0.6",
    "prettier": "^2.2.1",
    "supertest": "^6.1.3",
    "ts-jest": "^27.0.3",
    "ts-loader": "^8.0.17",
    "ts-node": "^9.1.1",
    "tsconfig-paths": "^3.9.0",
    "typescript": "^4.1.5"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\.spec\.ts$",
    "transform": {
      "^.+\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}

我的docker文件:

FROM node:14.17-alpine

# Copy project to the image
WORKDIR /srv/app
RUN mkdir static
COPY . /srv/app

# Install dependencies
RUN npm install

# Build and run the nest project
CMD ["npm", "run", "start:debug"]

我的配置:macOS Monterey 12.3.1 顺便说一句,另一位开发者成功推出了这个应用程序。他有一台 Windows 10 台机器。

我再说一遍:很长一段时间一切正常。 package.jsonDockerfile 在此期间完全没有改变。而且是最近才开始出来的。

@nestjs/cli dev 依赖项应该与其余 @nestjs/ 依赖项一起出现在版本 8 上。 @nestjs/cli v5 没有 start 命令