SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.
See original GitHub issueI 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:
The code that caused the error:
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:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Vibing - Could you please share webpack settings. I would like to refer them as I am facing same issue.
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