vue3.0+vite+ts项目搭建(报错处理)


报错一

warning package.json: No license field
$ vue-tsc --noEmit && vite build

 解决方案,添加这两行,只添加一个是没有用的

 报错二

node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1193:6 - error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.

 把tsconfig.json中的isolatedModules设置为false

报错三

yarn dev 不报错,build就报错

$ vue-tsc --noEmit && vite build
src/pages/home.vue:9:8 - error TS2339: Property 'appContext' does not exist on type 'ComponentInternalInstance | null'.

src/utils/request.ts:7:16 - error TS7016: Could not find a declaration file for module 'qs'

 解决方式将package.json中的build部分改掉

 改成这个样子就不再报错也可以正常打包了