question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.

See original GitHub issue

I use webpack@4.28.4 and babel@7.2.0 in my project.

{
	"@babel/cli": "^7.2.0",
	"@babel/core": "^7.2.0",
	"@babel/plugin-proposal-class-properties": "^7.2.1",
	"@babel/plugin-proposal-decorators": "^7.3.0",
	"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
	"@babel/plugin-syntax-dynamic-import": "^7.2.0",
	"@babel/plugin-proposal-optional-chaining": "7.2.0",
	"@babel/polyfill": "^7.2.5",
	"@babel/preset-env": "^7.2.0",
	"@babel/preset-react": "^7.0.0",
	"@babel/preset-typescript": "^7.1.0"
}

But the project can’t run in iPhone IOS9 Safari, it has a compile error: WX20190320-135448@2x

The code that caused the error: 2

I tried to modify @babel/env to fix this error:

"presets": [
    [
      "@babel/env",
      {
        "useBuiltIns": "usage",
        "targets": {
          "chrome": 52,
          "browsers": ["last 2 versions", "safari 7"]
        },
        "loose": true
      }
    ]
  ],

but it is invalid…

I need a solution, please help me. (My English is not good, please forgive me.)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
gupnee81commented, May 21, 2019

@Vibing - Could you please share webpack settings. I would like to refer them as I am facing same issue.

2reactions
simkessycommented, May 30, 2019

Make sure you have the latest @babel/polyfill.

They introduced a bug that caused this error.

Run npm i @babel/polyfill@latest and it should fix the problem: https://github.com/babel/babel/pull/9812

Read more comments on GitHub >

github_iconTop Results From Across the Web

bundle.js:1 SyntaxError: Unexpected keyword 'const'. Const ...
js:1 SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. My webpack.config.json has this rule: rules: ...
Read more >
Vue-cli and iOS 9 SyntaxError: Unexpected keyword 'const ...
Const declarations are not supported in strict mode. The const keyword comes from the email-regex lib wich is not tranformed by babel.
Read more >
Const Keyword Is Not Allowded In The Strict Mode In React ...
Nuxt js/Babel SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. 1. I have a web application that I create...
Read more >
Full-Page monitor for https page is not working as expected
SyntaxError : Unexpected keyword 'const'. Const declarations are not supported in strict mode.
Read more >
[Solved]-Nuxt js/Babel `SyntaxError: Unexpected keyword ...
Coding example for the question Nuxt js/Babel `SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.`-babel.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found