React Native捆绑: 语法错误: 意外的令牌:操作符 (*)

3
当我尝试使用以下命令来打包我的应用程序时:
react-native bundle --platform ios --dev false \
    --entry-file index.ios.js --bundle-output iOS/main.jsbundle

我遇到了以下错误,但没有其他细节信息:
SyntaxError: Unexpected token: operator (*)

就我所知,这个方法是可以行得通的(使用--dev true):

react-native bundle --platform ios --dev true \
    --entry-file index.ios.js --bundle-output iOS/main.jsbundle

我猜测问题可能出现在UglifyJS步骤中的某个位置,也许与以下相关:

https://github.com/mishoo/UglifyJS2/issues/1199

有什么提示吗?欢迎提供挖掘更深层次问题的建议!谢谢!

1个回答

5
我们使用以下方法找到了该行的行号:

./node_modules/.bin/esvalidate --formatter=sublime.js ios/main.jsbundle

问题出在使用了ES6运算符**,回退到使用Math.pow()函数。

在我的情况下,由于我替换了 Math.pow 为 *操作符 ()**,因为 ESLint 提示,导致 main.jsbundle 构建失败。捆绑错误是 *Unexpected token: operator ()**。 如果没有 main.jsbundle 运行 esvalidate,有没有办法找到行号?在我的情况下,我怀疑问题并使用正则表达式找到了它。是否有 react-native bundleverbose 选项? - Ed of the Mountain

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接