vue项目编译出现报错Parsing error: ‘import‘ and ‘export‘ may appear only with ‘sourceType

2,025 阅读1分钟

今天new了一个项目,在搭建新的vue项目,其中引入了部分依赖,在run的过程中出现了以下报错信息:

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

解决方法如下: 找到项目的.eslintrc.js文件,在parserOptions增加以下代码,重新编译即可。

 parserOptions: {
    sourceType: 'module'
  },