Skip to content

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

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

Closed
qmhc opened this issue Mar 25, 2022 · 7 comments
Closed

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

qmhc opened this issue Mar 25, 2022 · 7 comments

Comments

@qmhc
Copy link

qmhc commented Mar 25, 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.

@sqal
Copy link
Contributor

sqal commented Mar 25, 2022

add "skipLibCheck": true to your tsconfig.json

@posva
Copy link
Member

posva commented Mar 25, 2022

@wkrick
Copy link

wkrick commented Oct 14, 2022

@sqal

add "skipLibCheck": true to your tsconfig.json

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

@f1am3d
Copy link

f1am3d commented Mar 19, 2023

@sqal

add "skipLibCheck": true to your tsconfig.json

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

It does.

@adambergman
Copy link

@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?

@Ge6ben
Copy link

Ge6ben commented Jun 19, 2023

I fixed it by installing it !!

npm install --save-dev @babel/types

@cuonghuynh
Copy link

@Ge6ben it works for me. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2023
mcenkar added a commit to mcenkar/core-vue that referenced this issue Mar 15, 2024
fixes: vuejs#5625, vuejs#6891, vuejs#8917

Moved @babel/types from dev dependencies to normal dependencies. In this case
npm will correctly resolve dependency under configurations described in related
issues.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants