隐藏

Element plus 在vite2 和vue3时build打包失败

发布:2023/10/17 21:16:49作者:管理员 来源:本站 浏览次数:510

PS E:\download\maku-element-admin-master> npm run build

> maku-element-admin@1.0.0 build E:\download\maku-element-admin-master
> vue-tsc --noEmit && vite build

node_modules/element-plus/es/components/select/index.d.ts:6334:38 - error TS2304: Cannot find name 'Options'.

6334         type: import("vue").PropType<Options>;
                                          ~~~~~~~

node_modules/element-plus/es/components/select/index.d.ts:6335:24 - error TS2304: Cannot find name 'Options'.

6335         default: () => Options;
                            ~~~~~~~

node_modules/element-plus/es/components/tree-v2/index.d.ts:99:511 - error TS2300: Duplicate identifier 'event'.

99     emit: ((event: "current-change", data: import("../tree/src/tree.type").TreeNodeData, node: import("./src/types").TreeNode) => void) & ((event: "node-expand", data: import("../tree/src/tree.type").TreeNodeData, node: import("./src/types").TreeNode) => void) & ((event: "check-change", data: import("../tree/src/tree.type").TreeNodeData, checked: boolean) => void) & ((event: "node-click", data: import("../tree/src/tree.type").TreeNodeData, node: import("./src/types").TreeNode, e: MouseEvent) => void) & ((event: "node-contextmenu", event: Event, data: import("../tree/src/tree.type").TreeNodeData, node: import("./src/types").TreeNode) => void) & ((event: "node-collapse", data: import("../tree/src/tree.type").TreeNodeData, node: import("./src/types").TreeNode) => void) & ((event: "check", data: import("../tree/src/tree.type").TreeNodeData, checkedInfo: import("./src/types").CheckedInfo) => void);

解决方法
在tsconfig.json文件中"compilerOptions"选项下加入
“skipLibCheck”: true


{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "esnext",
    "useDefineForClassFields": true,
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
//    "allowJs": true,
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "skipLibCheck":true,
    "lib": ["esnext", "dom"],
    "types": [
      "web-bluetooth",
      "vite/client",
      "vite-plugin-svg-icons/client"
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
  "exclude": ["node_modules"]
}