I have a nodejs project which uses nx to manage multiple packages, the structure is:
packages/my-proj1/src/*.ts
packages/my-proj2/src/*.ts
...
the my-prod2 has dependency on my-proj1, so in the package.json under my-proj2, it has dependency:
"dependencies": {
"my-proj1": "*",
}
in the code of my-proj2, it imports files from my-proj1 like:
import { ... } from 'my-proj1/src`
as you can see, it has to put src on the import statement. How can I make it work by removing the src folder from the import statement in my-proj2?
You should have a
tsconfig.base.jsonfile in the root of the monorepo where these paths are setup.All you have to is change the
my-proj1path to include thesrcdirectory.Though it's usually recommended to have a single file that exports everything from a project, and you'd then reference just that file:
Then on the
tasconfig.base.json: