@Speakermen

Почему миграции не работают Not enough non-option arguments: got 0, need at least 1?

Читал но не нашёл проблему Генерация миграции с помощью cli

PS D:\projects\nestproject1> npm run migrate:create table

> nestproject1@0.0.1 migrate:create
> npm run build && npm run typeorm migration:create -- -n table


> nestproject1@0.0.1 build
> nest build


> nestproject1@0.0.1 typeorm
> node --require ts-node/register ./node_modules/typeorm/cli.js migration:create -n table

cli.js migration:create <path>

Creates a new migration file.

Options:
  -h, --help       Show help                                           [boolean]
  -o, --outputJs   Generate a migration file on Javascript instead of Typescript
                                                      [boolean] [default: false]
  -t, --timestamp  Custom timestamp for the migration name
                                                       [number] [default: false]
  -v, --version    Show version number                                 [boolean]

Not enough non-option arguments: got 0, need at least 1


.env
DATABASE_TYPE=mysql
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USERNAME=root
DATABASE_PASSWORD=root
DATABASE_NAME=app1


app.module.ts
import { Module } from '@nestjs/common';
import { AlbumsModule } from './albums/albums.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: process.env.DATABASE_HOST,
      port: +process.env.DATABASE_PORT,
      username: process.env.DATABASE_USERNAME,
      password: process.env.DATABASE_PASSWORD,
      database: process.env.DATABASE_NAME,
      //entities: [],
      //entities: [__dirname + '/entity/*{.js,.ts}'],
      entities: ['dist/**/*.entity{.ts,.js}'],
      migrations: ['dist/migrations/**/*{.ts,.js}'],
      autoLoadEntities: false,
      synchronize: false,
    }),
    AlbumsModule,
  ],
})
export class AppModule {}


package.json
{
  "name": "nestproject1",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "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/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json",
    "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
    "migrate:run": "npm run build && npm run typeorm migration:run",
    "migrate:generate": "npm run build && npm run typeorm migration:generate -- -n",
    "migrate:create": "npm run build && npm run typeorm migration:create -- -n",
    "migrate:revert": "npm run build && npm run typeorm migration:revert",
    "migrate:show": "npm run build && npm run typeorm migration:show",
    "migrate:drop": "npm run build && npm run typeorm schema:drop",
    "migrate:fresh": "npm run build && npm run typeorm schema:drop && npm run typeorm migration:run"
  },
  "dependencies": {
    "@nestjs/common": "^9.0.0",
    "@nestjs/config": "^2.2.0",
    "@nestjs/core": "^9.0.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/platform-express": "^9.0.0",
    "@nestjs/typeorm": "^9.0.1",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.13.2",
    "mysql2": "^2.3.3",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.2.0",
    "typeorm": "^0.3.11"
  },
  "devDependencies": {
    "@nestjs/cli": "^9.0.0",
    "@nestjs/schematics": "^9.0.0",
    "@nestjs/testing": "^9.0.0",
    "@types/express": "^4.17.13",
    "@types/jest": "29.2.4",
    "@types/node": "18.11.18",
    "@types/supertest": "^2.0.11",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.0.0",
    "eslint": "^8.0.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "jest": "29.3.1",
    "prettier": "^2.3.2",
    "source-map-support": "^0.5.20",
    "supertest": "^6.1.3",
    "ts-jest": "29.0.3",
    "ts-loader": "^9.2.3",
    "ts-node": "^10.0.0",
    "tsconfig-paths": "4.1.1",
    "typescript": "^4.7.4"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}
  • Вопрос задан
  • 193 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы