解决vite构建vue3项目报错
# 解决vite构建vue3/element-plus/ts项目错误
> vue-tsc --noEmit && vite build
node_modules/element-plus/lib/el-cascader-panel/index.d.ts:5:15 - error TS2307: Cannot find module './src/types' or its corresponding type declarations.
5 export * from './src/types';
~~~~~~~~~~~~~
node_modules/element-plus/lib/el-cascader-panel/src/config.d.ts:2:93 - error TS2307: Cannot find module './types' or its corresponding type declarations.
2 import { CascaderValue, CascaderOption, CascaderConfig, CascaderProps, ExpandTrigger } from './types';
~~~~~~~~~
node_modules/element-plus/lib/el-cascader-panel/src/index.vue.d.ts:2:18 - error TS2307: Cannot find module './node' or its corresponding type declarations.
2 import Node from './node';
~~~~~~~~
node_modules/element-plus/lib/el-cascader-panel/src/index.vue.d.ts:4:65 - error TS2307: Cannot find module './types' or its corresponding type declarations.
4 import type { CascaderValue, CascaderOption, RenderLabel } from './types';
~~~~~~~~~
node_modules/element-plus/lib/el-descriptions-item/index.d.ts:2:30 - error TS2307: Cannot find module '../descriptions/src/description-item' or its corresponding type declarations.
2 import DescriptionsItem from '../descriptions/src/description-item';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-form/index.d.ts:5:15 - error TS2307: Cannot find module './src/token' or its corresponding type declarations.
5 export * from './src/token';
~~~~~~~~~~~~~
node_modules/element-plus/lib/el-form/src/form.vue.d.ts:4:44 - error TS2307: Cannot find module './token' or its corresponding type declarations.
4 import type { ValidateFieldCallback } from './token';
~~~~~~~~~
node_modules/element-plus/lib/el-popper/index.d.ts:5:49 - error TS2307: Cannot find module './src/use-popper/defaults' or its corresponding type declarations.
5 export { default as defaultProps, Effect } from './src/use-popper/defaults';
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-popper/index.d.ts:7:66 - error TS2307: Cannot find module './src/use-popper/defaults' or its corresponding type declarations.
7 export type { TriggerType, IPopperOptions, PopperInstance } from './src/use-popper/defaults';
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-popper/src/renderers/popper.d.ts:2:29 - error TS2307: Cannot find module '../use-popper/defaults' or its corresponding type declarations.
2 import type { Effect } from '../use-popper/defaults';
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-popper/src/use-popper/index.d.ts:2:37 - error TS2307: Cannot find module './defaults' or its corresponding type declarations.
2 import type { IPopperOptions } from './defaults';
~~~~~~~~~~~~
node_modules/element-plus/lib/el-popper/src/use-popper/index.d.ts:802:15 - error TS2307: Cannot find module './defaults' or its corresponding type declarations.
802 export * from './defaults';
~~~~~~~~~~~~
node_modules/element-plus/lib/el-row/index.d.ts:1:17 - error TS2307: Cannot find module '../col/src/row' or its corresponding type declarations.
1 import Row from '../col/src/row';
~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-table-column/index.d.ts:1:25 - error TS2307: Cannot find module '../table/src/tableColumn' or its corresponding type
declarations.
1 import TableColumn from '../table/src/tableColumn';
~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-table/src/store/index.d.ts:3:30 - error TS2307: Cannot find module '../table/defaults' or its corresponding type declarations.
3 import { Filter, Sort } from '../table/defaults';
~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-table/src/table-column/defaults.d.ts:3:23 - error TS2307: Cannot find module '../table/defaults' or its corresponding type declarations.
3 import { Table } from '../table/defaults';
~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-table/src/table-header/index.d.ts:2:22 - error TS2307: Cannot find module '../table/defaults' or its corresponding type declarations.
2 import { Sort } from '../table/defaults';
~~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-table/src/table-layout.d.ts:4:23 - error TS2307: Cannot find module './table/defaults' or its corresponding type declarations.
4 import { Table } from './table/defaults';
~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-table/src/table.vue.d.ts:2:23 - error TS2307: Cannot find module './table/defaults' or its corresponding type declarations.
2 import { Table } from './table/defaults';
~~~~~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-tree/src/model/tree-store.d.ts:1:18 - error TS2307: Cannot find module './node' or its corresponding type declarations.
1 import Node from './node';
~~~~~~~~
node_modules/element-plus/lib/el-tree/src/tree.type.d.ts:2:18 - error TS2307: Cannot find module './model/node' or its corresponding type declarations.
2 import Node from './model/node';
~~~~~~~~~~~~~~
node_modules/element-plus/lib/el-tree/src/tree.vue.d.ts:2:18 - error TS2307: Cannot find module './model/node' or its corresponding type declarations.
2 import Node from './model/node';
~~~~~~~~~~~~~~
Found 22 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! developer-register-web@0.0.0 build: `vue-tsc --noEmit && vite build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the developer-register-web@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\carmineprince\AppData\Roaming\npm-cache\_logs\2021-08-02T09_19_46_072Z-debug.log
PS F:\XXXX\8.DeveloperPlatform\developer-register-web>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
问题原因可能是vue-tsc的bug
# 修改vite.config.js
中build
构建方式
原:
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview",
"prepare": "husky install"
}
1
2
3
4
5
6
2
3
4
5
6
修改后:
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"prepare": "husky install"
}
1
2
3
4
5
6
2
3
4
5
6
上次更新: 10/21/2021, 1:52:09 PM