Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Cannot find module error when entities are imported using absolute path #22

Open
hitankar-freshworks opened this issue Nov 24, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@hitankar-freshworks
Copy link

hitankar-freshworks commented Nov 24, 2020

When using absolute path for importing entities, I get the following error:

›   Error: Cannot find module 'src/category/entities/category.entity'
 ›   Require stack:
 ›   - /usr/src/app/src/photo/entities/photo.entity.ts
 ›   - /usr/src/app/node_modules/typeorm/util/DirectoryExportedClassesLoader.js
 ›   - /usr/src/app/node_modules/typeorm/connection/ConnectionMetadataBuilder.js
 ›   - /usr/src/app/node_modules/typeorm/connection/Connection.js
 ›   - /usr/src/app/node_modules/typeorm/connection/ConnectionManager.js
 ›   - /usr/src/app/node_modules/typeorm/index.js
 ›   - /usr/src/app/node_modules/typeorm-uml/lib/TypeormUmlCommand.js
 ›   - /usr/src/app/node_modules/typeorm-uml/bin/run

This is how I am importing category
import { CategoryEntity } from 'src/module-1/entities/category.entity';

I have not found a way to resolve this and the only way these works is using relative paths. Is it possible to have support for using absolute paths when importing entities?

@eugene-manuilov eugene-manuilov added the bug Something isn't working label Nov 26, 2020
@eugene-manuilov
Copy link
Owner

Hi, @hitankar-freshworks. Thanks for submitting it. Is your project publicly available? I want to see how it is configured to understand how to solve this problem. If not, can you create a small repo on GitHub that replicates your project configuration and has two tiny entities?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants