Skip to content

使用TypeScript时似乎缺少 “@types/node” 依赖,以及路径别名问题 #12

@tthzwq

Description

@tthzwq

使用TypeScript时似乎缺少 “@types/node” 依赖

路径别名配置似乎也有问题

 > html:src/App.vue:5:7: error: Could not resolve "@/components/HelloWorld.vue" (the plugin "vite:dep-scan" didn't set a resolve directory)
    5 │ import '@/components/HelloWorld.vue'
      ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > html:/src/views/HomeView.vue:5:7: error: Could not resolve "@/components/TheWelcome.vue" (the plugin "vite:dep-scan" didn't set a resolve directory)
    5 │ import '@/components/TheWelcome.vue'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// import { fileURLToPath } from 'url'
import { resolve } from 'path'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx()],
  resolve: {
    alias: {
      //  '@/': fileURLToPath(new URL('./src/', import.meta.url))
      '@': resolve(__dirname, 'src')
    }
  }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions