Phantomjs: SyntaxError: Unexpected token 'const'

Created on 17 Nov 2016  路  8Comments  路  Source: ariya/phantomjs

Hi I use PhantomJS 2.1.7 on MacOS, current I updated my webpack to 2.1.0-beta.27 and I encounter the following error when I run npm test, does anyone has the same problem?

Here's my repo

2016-11-17 6 26 25

Here's my dependencies :

"dependencies": {
    "autoprefixer": "^6.5.3",
    "axios": "^0.15.2",
    "babel-core": "^6.18.2",
    "babel-runtime": "^6.18.0",
    "better-npm-run": "0.0.13",
    "chalk": "^1.1.3",
    "compression": "^1.6.2",
    "express": "^4.14.0",
    "extract-text-webpack-plugin": "^2.0.0-beta.3",
    "helmet": "^3.1.0",
    "hpp": "^0.2.1",
    "immutable": "^3.8.1",
    "morgan": "^1.7.0",
    "opn": "^4.0.2",
    "react": "^15.4.0",
    "react-addons-shallow-compare": "^15.4.0",
    "react-dom": "^15.4.0",
    "react-helmet": "^3.2.2",
    "react-hot-loader": "^3.0.0-beta.6",
    "react-immutable-proptypes": "^2.1.0",
    "react-redux": "^4.4.6",
    "react-router": "^3.0.0",
    "react-router-redux": "^4.0.7",
    "redbox-react": "^1.3.3",
    "redux": "^3.6.0",
    "redux-immutable": "^3.0.8",
    "redux-thunk": "^2.1.0",
    "serialize-javascript": "^1.3.0",
    "serve-favicon": "^2.3.2",
    "stylelint-webpack-plugin": "^0.4.0",
    "webpack": "^2.1.0-beta.27",
    "webpack-dev-middleware": "^1.8.4",
    "webpack-hot-middleware": "^2.13.2",
    "webpack-isomorphic-tools": "^2.6.4"
  },
  "devDependencies": {
    "babel-eslint": "^7.1.0",
    "babel-loader": "^6.2.7",
    "babel-plugin-istanbul": "^3.0.0",
    "babel-plugin-system-import-transformer": "^2.4.0",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-latest": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-0": "^6.16.0",
    "chai": "^3.5.0",
    "chai-enzyme": "^0.6.0",
    "coveralls": "^2.11.15",
    "css-loader": "^0.25.0",
    "enzyme": "^2.6.0",
    "eslint": "^3.10.2",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-loader": "^1.6.1",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^2.2.3",
    "eslint-plugin-react": "^6.7.1",
    "image-webpack-loader": "^3.0.0",
    "imports-loader": "^0.6.5",
    "json-loader": "^0.5.4",
    "karma": "^1.3.0",
    "karma-cli": "^1.0.1",
    "karma-coverage": "^1.1.1",
    "karma-mocha": "^1.3.0",
    "karma-mocha-reporter": "^2.2.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^1.8.0",
    "mocha": "^3.1.2",
    "node-sass": "^3.13.0",
    "nodemon": "^1.11.0",
    "null-loader": "^0.1.1",
    "phantomjs": "^2.1.7",
    "postcss": "^5.2.5",
    "postcss-loader": "^1.1.1",
    "react-addons-test-utils": "^15.4.0",
    "react-hot-loader": "^3.0.0-beta.6",
    "redux-mock-store": "^1.2.1",
    "rimraf": "^2.5.4",
    "sass-loader": "^4.0.2",
    "sinon": "^2.0.0-pre.4",
    "style-loader": "^0.13.1",
    "stylelint": "^7.5.0",
    "stylelint-config-standard": "^14.0.0",
    "url-loader": "^0.5.7"
  }

All 8 comments

There is a const keyword in your javascript, but the webkit version in phantomjs doesn't yet support this syntax.

@Epskampie It works fine before...

Yeah, you used a new webpack, newer webpack targets modern browsers, modern browsers all support const, webpack outputs const, phantomjs doesn't support const. Q.E.D.

Downgrade your webpack, or don't use it at all.

@Epskampie That's too bad... seems I need to wait for PhantomJS support these features.

PhantomJS 2.5 will support full specification of ES2015.

@Vitallium When it will be released?

@wellyshen when it is ready

Seems the chai-enzyme 0.6.1 fix the problem

Was this page helpful?
0 / 5 - 0 ratings