yarn build 来打包项目,报错:You may need an additional loader to handle the result of these loaders.

在使用Yarn build打包Vue3项目时遇到错误,原因是缺少TypeScript配置。修复方法是确保在项目中安装并配置了TypeScript,同时检查模板文件中script标签的lang属性设置。修复后,打包过程恢复正常,强调了在引用模板前仔细阅读文档的重要性。
摘要由CSDN通过智能技术生成

用yarn build 来打包项目,发现开始疯狂报错

PS D:\sx1\xiaochajian\vue3-h5-template> yarn build
yarn run v1.22.19
$ vue-cli-service build
postcss-px-to-viewport: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating

|  Building for production...[@vue/compiler-sfc] the >>> and /deep/ combinators have been deprecated. Use :deep() instead.

|  Building for production...

 ERROR  Failed to compile with 1 error                                                                                                                                                          17:05:36

 error  in ./src/views/result/defeat.vue?vue&type=script&setup=true&lang=ts

Module parse failed: Unexpected token (22:12)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/vue-loader-v16/dist/index.js
You may need an additional loader to handle the result of these loaders.
|
|
> return (_ctx: any,_cache: any) => {
|   const _component_van_image = _resolveComponent("van-image")
|   const _component_van_button = _resolveComponent("van-button")

 @ ./src/views/result/defeat.vue?vue&type=script&setup=true&lang=ts 1:0-194 1:0-194 1:195-378 1:195-378
 @ ./src/views/result/defeat.vue
 @ ./src/router/routes.js
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./src/main.js

 ERROR  Build failed with errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

报错内容

发现原因是声明了,lang=“ts”

<script setup lang="ts">

由于引用的是模板,所以开始对比查看之前TS运行正常的项目和此项目的不同之处。
发现在package.json中typescript在报错项目中根本没有,仔细查看了文档,发现没有ts的内容

在这里插入图片描述

改动代码内容后,yarn build 正常

引用模板之前,一定要仔细阅读文档。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值