weex对es6语法报错,...

根据官网,进行weex的初始化安装,最后启动的时候,报错

H:\workspace\webstorm\weex-t>npm start

> weex-t@1.0.0 start H:\workspace\webstorm\weex-t
> npm run serve


> weex-t@1.0.0 serve H:\workspace\webstorm\weex-t
> webpack-dev-server --env.NODE_ENV=development --progress

H:\workspace\webstorm\weex-t\configs\webpack.common.conf.js:95
    ...webEntry,
    ^^^
SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (H:\workspace\webstorm\weex-t\configs\webpack.dev.conf.js:1:84)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! weex-t@1.0.0 serve: `webpack-dev-server --env.NODE_ENV=development --progress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weex-t@1.0.0 serve 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!     C:\Users\thinklight\AppData\Roaming\npm-cache\_logs\2018-02-27T08_33_16_191Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! weex-t@1.0.0 start: `npm run serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weex-t@1.0.0 start 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!     C:\Users\thinklight\AppData\Roaming\npm-cache\_logs\2018-02-27T08_33_16_239Z-debug.log

是对webpack.common.conf.js中的...报语法错误,这个是官方默认的初始化代码,要怎么解决呢

const webConfig = {
  entry: {
    ...webEntry,
    'vendor': [path.resolve('node_modules/phantom-limb/index.js')]
  },
  output: {
    path: helper.rootNode('./dist'),
    filename: '[name].web.js'
  },
  // 省略若干
}
阅读 5k
3 个回答

ES6暂时只能展开数组,以及把伪数组(特殊对象)展开为对象.

请问你解决了吗 我也遇到这个问题了

@我在等风也等你
需要用到Babel转码

    # 最新转码规则
    $ npm install --save-dev-g babel-preset-es2015

    # react 转码规则
    $ npm install --save-dev-g babel-preset-react

    # 不同阶段语法提案的转码规则(共有4个阶段),选装一个
    $ npm install --save-dev babel-preset-stage-0
    $ npm install --save-dev babel-preset-stage-1
    $ npm install --save-dev babel-preset-stage-2
    $ npm install --save-dev babel-preset-stage-3
    然后,将这些规则加入.babelrc
      {
            "presets": [
            "es2015",
            "react",
            "stage-2"
            ],
            "plugins": []
        }
    #babel-cli工具
    $ npm install --global babel-cli

在进行weex的初始化

    weex create weex-xx

新建的工程的js语法都没问题了
旧代码

entry: {
    ...webEntry,
    'vendor': [path.resolve('node_modules/phantom-limb/index.js')]
  },

新代码

  entry: Object.assign(webEntry, {
    'vendor': [path.resolve('node_modules/phantom-limb/index.js')]
  }),
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏