$ gulp
[18:09:47] Failed to load external module @babel/register
[18:09:47] Requiring external module babel-register
C:\users\astros\file\es6pro\node_modules\[email protected]@babel-core\lib\transformation\file\opti ons\build-config-chain.js:154
throw err;
^
SyntaxError: C:\users\astros\file\es6pro\.babelrc: Error while parsing JSON - Unexpected EOF at lin e 1 column 2 of the JSON5 data. Still to read: ""
at error (C:\users\astros\file\es6pro\node_modules\[email protected]@json5\lib\json5.js:56:25)
at word (C:\users\astros\file\es6pro\node_modules\[email protected]@json5\lib\json5.js:393:13)
at value (C:\users\astros\file\es6pro\node_modules\[email protected]@json5\lib\json5.js:493:56)
at Object.parse (C:\users\astros\file\es6pro\node_modules\[email protected]@json5\lib\json5.js:508:1 8)
at ConfigChainBuilder.addConfig (C:\users\astros\file\es6pro\node_modules\[email protected]@ba bel-core\lib\transformation\file\options\build-config-chain.js:150:65)
at ConfigChainBuilder.findConfigs (C:\users\astros\file\es6pro\node_modules\[email protected]@ babel-core\lib\transformation\file\options\build-config-chain.js:96:16)
at buildConfigChain (C:\users\astros\file\es6pro\node_modules\[email protected]@babel-core\lib \transformation\file\options\build-config-chain.js:61:13)
at OptionManager.init (C:\users\astros\file\es6pro\node_modules\[email protected]@babel-core\l ib\transformation\file\options\option-manager.js:354:58)
at compile (C:\users\astros\file\es6pro\node_modules\[email protected]@babel-register\lib\ node.js:103:45)
at loader (C:\users\astros\file\es6pro\node_modules\[email protected]@babel-register\lib\n ode.js:144:14)
The reason why
occurs above is because babelrc is empty
, in babelirc.js, write
//presets转成2015
//写法需安装cnpm install babel-preset-es2015 --save-dev
{
"presets":["es2015"]
}
ok