求助:导入jspdf时报错

341 阅读4分钟

因为遇到一个需求,需要在前端生成pdf,然后我通过一些文档教程查到jspdf这个库,也是根据官方文档的示例导入的,但是在项目(vue-cli)运行时却报错了,请教一下大佬,这是啥原因啊?

报错如下:

 ERROR  Failed to compile with 2 errors                                                            12:44:12

 error  in ./node_modules/canvg/lib/index.es.js

export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)

 error  in ./node_modules/canvg/lib/index.es.js

export 'default' (imported as '_defineProperty') was not found in '@babel/runtime/helpers/defineProperty' (module has no exports)

ERROR in ./node_modules/canvg/lib/index.es.js 43:13-30
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 1285:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 1317:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 4692:205-220
export 'default' (imported as '_defineProperty') was not found in '@babel/runtime/helpers/defineProperty' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 5517:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 5532:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 5640:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 6234:205-220
export 'default' (imported as '_defineProperty') was not found in '@babel/runtime/helpers/defineProperty' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 6248:17-34
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 6386:201-216
export 'default' (imported as '_defineProperty') was not found in '@babel/runtime/helpers/defineProperty' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 6419:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54

ERROR in ./node_modules/canvg/lib/index.es.js 6495:11-28
export 'default' (imported as '_asyncToGenerator') was not found in '@babel/runtime/helpers/asyncToGenerator' (module has no exports)
 @ ./node_modules/jspdf/dist/jspdf.es.min.js 291:65-80
 @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 26:13-29 
 @ ./src/views/ship/anchorSettlement/index.vue?vue&type=script&lang=js 1:0-210 1:226-229 1:231-438 1:231-438
 @ ./src/views/ship/anchorSettlement/index.vue 2:0-56 3:0-51 3:0-51 10:2-8
 @ ./src/views/ sync ^\.\/.*$ ./ship/anchorSettlement/index.vue ./ship/anchorSettlement/index ./ship/anchorSettlement/ ./ship/anchorSettlement
 @ ./src/store/modules/permission.js 134:13-56
 @ ./src/store/index.js 13:41-72
 @ ./src/main.js 17:36-54