Subscribe on changes!

Cannot find module '@babel/types' or its corresponding type declarations

avatar
Mar 25th 2022

Version

3.2.31

Reproduction link

reproduction

Steps to reproduce

This project is created by create-vite:

pnpm create vite project -- --template vue-ts

Update dependencies to the latest version then change src/main.ts to src/index.ts:

{
  "devDependencies": {
    "@vitejs/plugin-vue": "^2.2.4",
    "typescript": "^4.6.3",
    "vite": "^2.8.6",
    "vue-tsc": "^0.33.7"
  }
}
import App from './App.vue'

export default App

Change vite.config.ts to build lib:

import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    lib: {
      entry: resolve(__dirname, 'src/index.ts'),
      name: 'Test',
      formats: ['es'],
      fileName: 'test'
    },
    rollupOptions: {
      external: ['vue']
    }
  },
  plugins: [
    vue()
  ]
})

Install project and run:

pnpm run build

What is expected?

Build successful.

What is actually happening?

image

Will take some errors and build fail.

If this is just a problem of vue-tsc (volar), please help migrate this issue, thanks.

avatar
Mar 25th 2022

add "skipLibCheck": true to your tsconfig.json

avatar
Oct 14th 2022

@sqal

add "skipLibCheck": true to your tsconfig.json

Does this fix anything or does it just hide the underlying issue?

avatar
Mar 19th 2023

@sqal

add "skipLibCheck": true to your tsconfig.json

Does this fix anything or does it just hide the underlying issue?

It does.

avatar
Apr 16th 2023

@sqal

add "skipLibCheck": true to your tsconfig.json

Does this fix anything or does it just hide the underlying issue?

It does.

I'm not sure that this "fixes" the issue as @f1am3d says. It seems like it just hides it to me. Sure, vue-tsc no longer complains about third party code in node_modules, but if you've got *.d.ts files to declare types for other libraries in your project, it skips them on the type check as well. That's not an option in my case. Is there a workaround to avoid node_modules but allow your own .d.ts files?

avatar
Jun 19th 2023

I fixed it by installing it !!

npm install --save-dev @babel/types
avatar
Jul 11th 2023

@Ge6ben it works for me. Thanks!