Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to require d.ts file in Lerna project #831

Closed
nehalist opened this issue May 12, 2019 · 3 comments
Closed

Unable to require d.ts file in Lerna project #831

nehalist opened this issue May 12, 2019 · 3 comments

Comments

@nehalist
Copy link

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.

@gianmarcotoso
Copy link

I was having the same issue and I solved it by adding "preserveSymlinks": true to my tsconfig.json file.

@nehalist
Copy link
Author

That fixed it, thanks a lot.

@mscottx88
Copy link

mscottx88 commented Oct 21, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants