Vue:npm run devエラーParsing error:The keyword'import'is reserved

1872 ワード

Vue:npm run devエラーParsing error:The keyword'import'is reserved
慕课网は腹が減ったか実戦プロジェクトで、初期ファイルをダウンロードした后.
$ npm install

あとで実行
$ npm run dev

後でエラーを報告します.
npm run dev

> [email protected] dev /Users/macroot/myWorkspaces/sell
> node build/dev-server.js

Listening at http://localhost:8080

webpack built 7cdc45250a9732c5a0f9 in 983ms
Hash: 7cdc45250a9732c5a0f9
Version: webpack 1.15.0
Time: 983ms
 Asset    Size  Chunks       Chunk Names
app.js  285 kB       0       app

ERROR in ./src/main.js

  ✘  http://eslint.org/docs/rules/  Parsing error: The keyword 'import' is reserved  
  /Users/macroot/myWorkspaces/sell/src/main.js:1:1
  import Vue from 'vue';
   ^


✘ 1 problem (1 error, 0 warnings)


Errors:
  1  http://eslint.org/docs/rules/null
Child html-webpack-plugin for "index.html":
         Asset   Size  Chunks       Chunk Names
    index.html  22 kB       0       
webpack: Failed to compile.
^C


これはeslintを構成する必要があるからです.
eslintの説明[1]によれば、2つの構成がある.ここでは、プロジェクトディレクトリの下で.eslintrc.jsを確立する方法を用いて構成する.
プロジェクトディレクトリの下にファイルを新規作成する
$ touch .eslintrc.js
.eslintrc.jsの内容を[2]:
module.exports = {
  root: true,
  parserOptions: {
    sourceType: 'module'
  },
  // required to lint *.vue files
  plugins: [
    'html'
  ],
  // add your custom rules here
  'rules': {
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  }
}

再稼働すれば正常です.
$ npm run dev

表示:
Listening at http://localhost:8080

リファレンス
[1] http://eslint.cn/docs/user-guide/configuring
[2] https://github.com/vuejs-templates/webpack/issues/92