babel presets es2015编译失败,显示SyntaxError: Unexpected 财富值64

2016-10-15 08:16发布

现有项目目录如下:

`-  |- src    `- test.js  |- node_modules  `- package.json

其中,test.js的代码如下:

var a = 10;

node_modules里面已经通过npm安装了babel-core,babel-preset-es2015

并且已经在全局安装了babel命令:npm install babel -g

此时,在项目根目录下运行:babel src/test.js --presets es2015,会报出如下的错误:

yntaxError: Unexpected token ILLEGAL (While processing preset: "/path/to/project/node_modules/babel-preset-es2015/lib/index.js")     at exports.runInThisContext (vm.js:53:16)     at Module._compile (module.js:373:25)     at Object.Module._extensions..js (module.js:416:10)     at Module.load (module.js:343:32)     at Function.Module._load (module.js:300:12)     at Module.require (module.js:353:17)     at require (internal/module.js:12:17)     at Object.<anonymous> (/path/to/project/node_modules/babel-preset-es2015/node_modules/babel-plugin-transform-es2015-function-name/node_modules/babel-runtime/node_modules/core-js/library/fn/object/get-own-property-symbols.js:1:63)     at Module._compile (module.js:409:26)     at Object.Module._extensions..js (module.js:416:10)

请问是什么原因导致编译不通过?谢过了!

1条回答

既然都配好了环境,那就用es2015(es6)的写法了写代码呀

一周热门 更多>