I've got a Lerna project with the following structure:
packages/
ComponentA/
ComponentB/
...
lerna.json
package.json
tsconfig.json
test.ts
ComponentA does depend on ComponentB, hence some files within it it import it via
# Within component A
import {whatever} from '@project/component-b';
When I try to use ComponentA now within the test.ts file (which is simply called via ts-node test.ts) I get the following error:
TypeError: Unable to require `.d.ts` file.
This is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension and loader (attached before `ts-node`) available alongside `index.ts`.
There are currently no .d.ts files at all - but importing via relative paths works fine (e.g. import {whatever} from '../../ComponentB/...';)
ts-node version is v8.0.3.
I was having the same issue and I solved it by adding "preserveSymlinks": true to my tsconfig.json file.
That fixed it, thanks a lot.
Confirmed. We upgraded to jest 24 and we ignored the ts-jest incompatibility issues. Then we upgraded ts-jest to 24 and got this error. I noticed the problem occurred in Linux (not Windows). Adding the preserveSymlinks setting resolving the issue.
We are using Lerna in a monorepo setup, if that helps.
Most helpful comment
I was having the same issue and I solved it by adding
"preserveSymlinks": trueto mytsconfig.jsonfile.