報錯一
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部分改掉
改成這個樣子就不再報錯也可以正常打包了
報錯四
打包報錯
這個是打包配置文件寫錯了,改成這樣就好了
報錯五
打包的時候出現以下報錯:
warnings when minifying css:
> <stdin>:9:1: warning: "@charset" must be the first rule in the file
9 │ }@charset "UTF-8";
解決方案:修改vite.config.ts文件配置
css部分加上charset: false
完整代碼如圖
報錯六
vant采用cdn引入的方式報錯
Uncaught (in promise) TypeError: Cannot read property 'proxy' of null
at Xe (vant.min.js:1)
解決方案,換用從vite.config.ts中引入CDN
上面這種報錯是在從index.html引入CDN的情況下報錯的
轉:https://www.cnblogs.com/ToBeBest/p/15597961.html