如何修复编译vuejs项目时出现的意外令牌错误



遵循以下步骤:

  1. 安装新的vuejs 2。不要更改package.json
  2. 安装vue-concept包。这是一个基于vuejs的Notion渲染器
  3. 将NotionRenderer对象注入任何页面,如官方示例中所示:import { NotionRenderer } from 'vue-notion'
  4. 运行npm run serveyarn serve(我都试过了)

。。。我在编译时得到以下错误:

error  in ./node_modules/vue-notion/dist/esm.js
Module parse failed: Unexpected token (1793:175)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|       // return empty notion decorated text if row is empty
>       return (this === null || this === void 0 ? void 0 : (_this$properties = this.properties) === null || _this$properties === void 0 ? void 0 : _this$properties[columnId]) ?? [[" ", false]];
|     },
| 
@ ./src/main.js 9:0-44
@ multi (webpack)-dev-server/client?http://192.168.0.107:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

问题是字符串末尾的无效合并运算符(??)。我已经尝试将@babel/plugin-proposal-nullish-coalescing-operator添加到babel.config中,但它仍然不起作用:

module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
],
plugins: [
'@babel/plugin-proposal-nullish-coalescing-operator',
],
}

我该怎么修?我应该使用什么样的加载程序来编译代码?

谢谢@Jonathan。我通过在vue.config.js:中添加transfile指令解决了这个问题

module.exports = {
transpileDependencies: ["vue-notion"]
}

最新更新