6

I get the following error:

ERROR in ./src/main.js

  error Parsing error: The keyword 'import' is reserved  
  /Users/staging/Desktop/sourcetree/viewer_web/src/main.js:1:1
  import Vue from 'vue'

For some reason the ES6 feature in my project is not being recognized?

I'm using Node 5.0 and this is my package.json:

{
  "name": "istaging-viewer",
  "description": "A Vue.js project",
  "author": "Alex <alexchen.info@gmail.com>",
  "private": true,
  "scripts": {
    "dev": "node build/dev-server.js",
    "build": "rimraf dist && webpack --progress --hide-modules --config build/webpack.prod.conf.js",
    "test": "karma start build/karma.conf.js --single-run"
  },
  "dependencies": {
    "aframe": "mozvr/aframe#dev",
    "bootstrap": "^3.3.6",
    "jquery": "^2.2.1",
    "lodash": "^4.4.0",
    "vue": "^1.0.16",
    "vue-resource": "^0.7.0",
    "vue-router": "^0.7.11"
  },
  "devDependencies": {
    "babel-core": "^6.0.0",
    "babel-loader": "^6.0.0",
    "babel-plugin-transform-runtime": "^6.0.0",
    "babel-preset-es2015": "^6.0.0",
    "babel-preset-stage-2": "^6.0.0",
    "babel-runtime": "^5.8.0",
    "bootstrap-webpack": "0.0.5",
    "connect-history-api-fallback": "^1.1.0",
    "css-loader": "^0.23.1",
    "eslint": "^1.10.3",
    "eslint-friendly-formatter": "^1.2.2",
    "eslint-loader": "^1.2.0",
    "eslint-plugin-html": "^1.3.0",
    "eventsource-polyfill": "^0.9.6",
    "exports-loader": "^0.6.3",
    "express": "^4.13.3",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.4",
    "function-bind": "^1.0.2",
    "html-loader": "^0.4.3",
    "html-webpack-plugin": "^2.8.1",
    "imports-loader": "^0.6.5",
    "inject-loader": "^2.0.1",
    "jasmine-core": "^2.4.1",
    "json-loader": "^0.5.4",
    "karma": "^0.13.15",
    "karma-jasmine": "^0.3.6",
    "karma-phantomjs-launcher": "^1.0.0",
    "karma-spec-reporter": "0.0.24",
    "karma-webpack": "^1.7.0",
    "less": "^2.6.0",
    "less-loader": "^2.2.2",
    "phantomjs-prebuilt": "^2.1.3",
    "rimraf": "^2.5.0",
    "style-loader": "^0.13.0",
    "stylus": "^0.53.0",
    "stylus-loader": "^1.5.1",
    "url-loader": "^0.5.7",
    "vue-hot-reload-api": "^1.2.0",
    "vue-html-loader": "^1.0.0",
    "vue-loader": "^8.1.3",
    "vue-style-loader": "^1.0.0",
    "webpack": "^1.12.2",
    "webpack-dev-middleware": "^1.4.0",
    "webpack-hot-middleware": "^2.6.0"
  }
}

What's a possible solution?

I thought it was a problem caused by eslint so I installed it globally but it didn't solve the problem.

alex
  • 7,111
  • 15
  • 50
  • 77
  • Does this answer your question? [Parsing Error The Keyword import is Reserved (SublimeLinter-contrib-eslint)](https://stackoverflow.com/questions/36002226/parsing-error-the-keyword-import-is-reserved-sublimelinter-contrib-eslint) – Henke Feb 26 '22 at 14:49

2 Answers2

4

You should add this to your .eslintrc file:

"parser": "babel-eslint"

This will fix your issue.

Iman Mohamadi
  • 6,552
  • 3
  • 34
  • 33
1

Node still uses common.js for modules. Take a look here https://nodejs.org/en/docs/es6/ for all the es6 supported features in node. If you want to use es6 imports you may have to use babel-node

gabesoft
  • 1,228
  • 9
  • 6
  • As you can see in my `package.json` I have babel installed. – alex Mar 11 '16 at 05:25
  • I was talking about babel-cli http://babeljs.io/docs/usage/cli/ you'd have to run it instead of node like so ``babel-node build/dev-server.js`` – gabesoft Mar 11 '16 at 07:20