@babel/parser throw an error when parsing object shorthand property async get () after updating to version 7.11.1
See original GitHub issueindex.js
export default {
async get () {}
};
package.json
{
"name": "babel-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.10.3"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"babel": "babel index.js"
},
"author": "",
"license": "ISC"
}
when running npm run babel
, I got an error below
{ SyntaxError: /Users/icefox/Desktop/babel-test/index.js: Unexpected token (2:11)
1 | export default {
> 2 | async get () {}
| ^
3 | };
at Parser._raise (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:763:17)
at Parser.raiseWithData (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:756:17)
at Parser.raise (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:750:17)
at Parser.unexpected (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:8930:16)
at Parser.parseIdentifierName (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:11017:18)
at Parser.parseIdentifier (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:10994:23)
at Parser.parseMaybePrivateName (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:10311:19)
at Parser.parsePropertyName (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:10795:155)
at Parser.parsePropertyDefinition (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:10708:14)
at Parser.parseObjectLike (/Users/icefox/Desktop/babel-test/node_modules/_@babel_parser@7.11.1@@babel/parser/lib/index.js:10612:25)
loc: Position { line: 2, column: 11 },
pos: 28,
code: 'BABEL_PARSE_ERROR' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! babel-test@1.0.0 babel: `babel index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the babel-test@1.0.0 babel script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/icefox/.tnpm/_logs/2020-08-05T05_53_09_257Z-debug.log
[tnpm] subprocess:/Users/icefox/.nvm/versions/node/v10.21.0/lib/node_modules/tnpm/lib/npm_child_process.js exit code: 1, signal: null
[tnpm] mainprocess exit code: 1
It works fine with async
with property name except get
, and older version of @babel/parser
, and in latest chrome and node v8, it turns out a valid syntax
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:16 (1 by maintainers)
Top Results From Across the Web
babel/parser/CHANGELOG.md - UNPKG
The CDN for @babel/parser. ... now correctly throws an error when there is a semicolon after the decorator: ... 248, export default async...
Read more >babel/parser - NPM Package Versions - Socket.dev
Start using Socket to analyze @babel/parser and its 0 dependencies to secure your ... #15163 fix: Throw error when compiling super() in arrow...
Read more >babel/parser
The Babel parser (previously Babylon) is a JavaScript parser used in Babel. The latest ECMAScript version enabled by default (ES2020). Comment attachment.
Read more >@babel/runtime: Versions | Openbase
#14557 Fix parsing of < after object literals with the jsx plugin (@JLHwung) ... #13410 fix: throw when async() call param is object...
Read more >Babel throwing errors on async/await syntax despite having ...
package.json. { "dependencies": { "babel-cli": "^6.18.0", "babel-plugin-transform-class-properties": "^6.18.0", ...
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
Fixed in
@babel/parser
7.11.2.If you use
yarn
, you can either manually remove@babel/parser
entries in yarn.lock and re-runyarn install
or useyarn-deduplicate
For temporary fix right now we are using this one: