Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulled from remote repo and getting: "Parsing error: The keyword 'import' is reserved"

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 <[email protected]>",
  "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.

like image 630
alex Avatar asked Mar 11 '16 04:03

alex


2 Answers

You should add this to your .eslintrc file:

"parser": "babel-eslint"

This will fix your issue.

like image 146
Iman Mohamadi Avatar answered Sep 30 '22 15:09

Iman Mohamadi


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

like image 38
gabesoft Avatar answered Sep 30 '22 16:09

gabesoft