简体   繁体   中英

TypeOrm migration - Error: Cannot find module

I'm trying npm run typeorm migration:run in my project and it is showing the error below.

Error during migration run: Error: Cannot find module 'src/permission/permission.entity'

migratino 运行期间出错:找不到模块“权限”

ormconfig.js

module.exports = {
  type: 'mysql',
  host: 'localhost',
  port: 33066,
  username: 'root',
  password: '123456',
  database: 'admin',
  synchronize: false,
  entities: ['./src/**/*.entity.ts'],
  migrations: ['./src/migrations/*.ts'],
  cli: {
    entitiesDir: './ts/',
    migrationsDir: './src/migrations',
  },
};

What am I doing wrong? This is my git repo: https://github.com/wesoz/udemy-nest-admin/tree/td/seed

You need to use a relative import path.

import { Permission } from '../permission/permission.entity';

You must add decorator @entity() to entity class

0

probably it's an node versioning error, so try to update your node version and check package.json file and package.lock.json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM