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

Fix: cannot find module 'conf' in Typescript projects #190

Closed
wants to merge 1 commit into from

Conversation

nosajio
Copy link

@nosajio nosajio commented Nov 19, 2023

I discovered that Typescript doesn't know where to look for the conf type declaration. The issue can be reproduced by creating a new typescript / node project, running npm install conf, and importing conf into a ts file without installing @types/conf.

Since the @types/conf package is now deprecated, I've added a line to the package.json to ensure the declaration file is always found in typescript projects.

image

The fix is confirmed to solve the issue by running tsc to see the import error, adding the types property the package file directly in node_modules/conf, and running tsc again to see a successful build.

@sindresorhus
Copy link
Owner

The problem is your tsconfig, not this package. The types are defined right here:

"types": "./dist/source/index.d.ts",

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm

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

Successfully merging this pull request may close these issues.

2 participants