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'

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';
Using typeorm@^0.3.10
This worked for me.
npm i -D tsconfig-paths
Adding this flag to the ts-node command -r tsconfig-paths/register
"migration:run": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run -d=ormconfig.ts"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With