-
Notifications
You must be signed in to change notification settings - Fork 310
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
Cannot find module 'graphql-request' or its corresponding type declarations. #880
Comments
Ok, so if I set Everything ELSE breaks though... 😭 Is there any way to make |
@tofsjonas unfortunately not, this is an ESM project. Are you stuck in the CJS world? https://github.com/jasonkuhrt/graphql-request?tab=readme-ov-file#typescript-setup |
Haha, well, I wish I wasn't. The repo I shared was a completely fresh nest.js project. (Sure, nest.js doesn't have as many downloads as graphql-request, but it's still a significant package) If I add (In my actual project, I have hundreds of files with thousands of imports.) To fix it I have to go into every single file that imports from another file and alter import { AppService } from './app.service'; to import { AppService } from './app.service.js'; Either that or figure out some bundler magic with babel or what have you. It would be so, so very nice not to have to do that... 🥺🐶 |
@tofsjonas if you use I've gotten that far updating my project, now trying to get Jest working with ESM.. So I agree this brings a challenge for some established projects. |
Now I just have to get the ci pipeline to work again. But I guess that can wait until Monday.. Thank you both for your time! 🙏 |
This poll might be relevant for you #863 |
Er, I take it back. When using Cannot find module '/Users/jonas/graphql-request-test/dist/app.module'
imported from /Users/jonas/graphql-request-test/dist/main.js If I add |
Here's how you can migrate your Typescript + Node application from commonjs to ESM:
I think that's it. That last step is most of the pain but if you're lucky it only affects a couple libraries you're using. If you wonder why your Node project needs to be forced to use ESM even though everything on NPM supports commonjs except this one library, you're not alone. ;) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Going to lock this issue now to keep my notification noise down. If you have comments about the library you can leave that in the discussions forum. There is also a poll I'm looking at occasionally to help gauge the impact of not supporting CJS linked to above. Sorry for users feeling the pain of CJS/ESM. Ultimately the way out of this is everyone dropping support for CJS and users upgrading their projects. Our Python 2/3 moment. |
Screenshot VS Code
Screenshot
npx tsc --noEmit
Description
When installing 7.0.1 typescript fails. 6.1.0 works as expected.
I have tried with both pnpm and npm. I haven't tried with yarn.
tsconfig.json
(I have tried with other tsconfig setups, but they all fail.)
Reproduction Steps/Repo Link
Repo: https://github.com/tofsjonas/graphql-request-test
Install and run
The text was updated successfully, but these errors were encountered: