编写2.js代码:
写一段这样的代码,我们使用webpack把es6语法转成es5语法,
webpack.config.js代码:
运行webpack
显示没有问题;
然后运行编译后的文件,出现如下问题,为什么呀?改如何解决????急。。。。。。。
PHP中文网2017-04-17 16:34:22
I have a question, why do you need to use webpack to compile on the server side?
Have you ever thought about making your server support babel?
Install babel-cli
Just let Node support babeljs. Moreover, the latest version of Node still supports many ES6 features by default
npm -g install babel-cli
Execute
babel-node es6.js