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

Could not find a declaration file for module '@babel/core'. #211

Closed
7 tasks done
saramorillon opened this issue Aug 19, 2023 · 2 comments
Closed
7 tasks done

Could not find a declaration file for module '@babel/core'. #211

saramorillon opened this issue Aug 19, 2023 · 2 comments

Comments

@saramorillon
Copy link

Describe the bug

When using @vitejs/plugin-react@4.0.4, I get this error when building my application:
image

I can get rid of this error by installing @types/babel__core, but I don't think it should be the user's responsibility to install a type on which a dependency depends.

Reproduction

https://github.com/saramorillon/inventory/tree/b612b372734dda6454872427a76b037050d50ed9

Steps to reproduce

In front directory, run yarn install followed by yarn build

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
    Memory: 6.41 GB / 15.93 GB
  Binaries:
    Node: 19.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 116.0.5845.96
    Edge: Spartan (44.22621.2134.0), Chromium (115.0.1901.203)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vitejs/plugin-react: ^4.0.4 => 4.0.4
    vite: ^4.4.9 => 4.4.9

Used Package Manager

yarn

Logs

node_modules/@vitejs/plugin-react/dist/index.d.ts:1:49 - error TS7016: Could not find a declaration file for module '@babel/core'. '/node_modules/@babel/core/lib/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/babel__core if it exists or add a new declaration (.d.ts) file containing declare module '@babel/core';

1 import { TransformOptions, ParserOptions } from '@babel/core';
~~~~~~~~~~~~~

Found 1 error.

error Command failed with exit code 1.

Validations

@ArnaudBarre
Copy link
Member

This is because you don't have skipLibCheck enabled in your tsconfig. This is very common and given that the first time it's been reported since the repo was split 7 months ago, this is even more common than I would expect.
Nonetheless maybe there is some usage of the plugin in vite.config.ts that is badly typed. I will look into it.

Checking lib types can help find issues in the libs you use but most of the time this is unactionable and this is why most template enable this TS flag.

@saramorillon
Copy link
Author

saramorillon commented Aug 20, 2023

I would rather not enable skipLibCheck is my tsconfig as it helps me find inconsistencies with the versions of the libs I use (e.g. if I end up with two different version of @types/react in my yarn.lock).
I'm looking forward the result of your investigations, thank you.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants