当前位置: 首页 > 工具软件 > pdfjs-dist > 使用案例 >

pdfjs-dist 编译报错

颜瀚漠
2023-12-01

Module parse failed: Unexpected token (2902:55)

File was processed with these loaders:

* ./node_modules/cache-loader/dist/cjs.js

* ./node_modules/babel-loader/lib/index.js

You may need an additional loader to handle the result of these loaders.

| intent: renderingIntent,

| renderInteractiveForms: renderInteractiveForms === true,

> annotationStorage: annotationStorage?.getAll() || null

| });

| }

原因:

vue-cli默认的配置不能编译草案语法 Optional chaining 、Nullish coalescing operator 、Private class features

增加babel编译插件

npm install --save-dev @babel/plugin-proposal-optional-chaining

npm install --save-dev @babel/plugin-proposal-nullish-coalescing-operator

npm install --save-dev @babel/plugin-proposal-private-methods

安装后在babel配置文件babel.config.js或.babelrc增加babel插件引用:

plugins: ['@babel/plugin-proposal-optional-chaining','@babel/plugin-proposal-nullish-coalescing-operator','@babel/plugin-proposal-private-methods']

 类似资料: