16

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'

Error during migratino run: Cannot find module 'permission'

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

3 Answers 3

28

You need to use a relative import path.

import { Permission } from '../permission/permission.entity';
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! Now I'm getting the error: RepositoryNotFoundError: No repository for "permissions" was found. Looks like this entity is not registered in current "default" connection?
No idea sorry, maybe you can ask a new question.
17

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"

1 Comment

This is the answer which worked for me
-2

You must add decorator @entity() to entity class

1 Comment

That's entirely unrelated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.