简体   繁体   中英

vite-plugin-pages got error Cannot find module '~pages' or its corresponding type declarations

I am creating my vue project with typescript via vite , and I use vite-plugin-pages for my router.

I got type error when I import routes from ~pages

Below is my code in my router:

import { createRouter, createWebHistory } from "vue-router";
import routes from "~pages"; // got error here

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});

export default router;

and error:

在此处输入图像描述

Add /// <reference types="vite-plugin-pages/client" /> in env.d.ts

It's mentioned in README .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM