search

Home  >  Q&A  >  body text

javascript - webpack 打包http服务器代码转es6,无法运行啦

编写2.js代码:

写一段这样的代码,我们使用webpack把es6语法转成es5语法,

webpack.config.js代码:


运行webpack

显示没有问题;

然后运行编译后的文件,出现如下问题,为什么呀?改如何解决????急。。。。。。。

大家讲道理大家讲道理2863 days ago593

reply all(1)I'll reply

  • PHP中文网

    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

    reply
    0
  • Cancelreply