webpack - 来自UglifyJs的renderer.js中的错误意外的标记点«(»

标签 webpack vue.js electron uglifyjs

版本:webpack 2.3.3

你好呀

我正在尝试使用Vuejs构建我的第一个Electron应用程序。在我打包应用程序之前,一切似乎都进展顺利。

当我运行npm run dev时,一切正常。

但是,当我运行npm build:darwin时,出现以下错误
ERROR in renderer.js from UglifyJs Unexpected token punc «(», expected punc «:» [renderer.js:26813,14]
它最终会编译,但是当我运行该应用程序时,出现白屏死机。

根据我的阅读,这可能是因为Uglifyjs无法编译ES6,但是您可以通过.babelrc文件中的以下内容来克服该问题

"renderer": {
  "presets": [
    ["es2015", { "modules": false }],
    "stage-0"
  ]
}

我不知道该如何调试。任何帮助将不胜感激。

谢谢

生成的debug.log是...
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.9.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'pack' ]
2 info using npm@4.2.0
3 info using node@v7.9.0
4 verbose run-script [ 'prepack', 'pack', 'postpack' ]
5 info lifecycle FormBuff@0.0.0~prepack: FormBuff@0.0.0
6 silly lifecycle FormBuff@0.0.0~prepack: no script for prepack, continuing
7 info lifecycle FormBuff@0.0.0~pack: FormBuff@0.0.0
8 verbose lifecycle FormBuff@0.0.0~pack: unsafe-perm in lifecycle true
9 verbose lifecycle FormBuff@0.0.0~pack: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/admin/Code/electron/formbuff/node_modules/.bin:/Users/admin/Code/electron/formbuff/node_modules/.bin:/Users/admin/.config/yarn/link/node_modules/.bin:/Users/admin/Code/electron/formbuff/node_modules/.bin:/Users/admin/.config/yarn/link/    node_modules/.bin:/usr/local/Cellar/yarn/0.23.2/libexec/bin/node-gyp-bin:/Users/admin/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/admin/.composer/vendor/bin:/Users/admin/go/bin
10 verbose lifecycle FormBuff@0.0.0~pack: CWD: /Users/admin/Code/electron/formbuff
11 silly lifecycle FormBuff@0.0.0~pack: Args: [ '-c', 'npm run pack:main && npm run pack:renderer' ]
12 silly lifecycle FormBuff@0.0.0~pack: Returned: code: 2  signal: null
13 info lifecycle FormBuff@0.0.0~pack: Failed to exec pack script
14 verbose stack Error: FormBuff@0.0.0 pack: `npm run pack:main && npm run pack:renderer`
14 verbose stack Exit status 2
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:194:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:194:7)
14 verbose stack     at maybeClose (internal/child_process.js:899:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid FormBuff@0.0.0
16 verbose cwd /Users/admin/Code/electron/formbuff
17 error Darwin 16.5.0
18 error argv "/usr/local/Cellar/node/7.9.0/bin/node" "/usr/local/bin/npm" "run" "pack"
19 error node v7.9.0
20 error npm  v4.2.0
21 error code ELIFECYCLE
22 error errno 2
23 error FormBuff@0.0.0 pack: `npm run pack:main && npm run pack:renderer`
23 error Exit status 2
24 error Failed at the FormBuff@0.0.0 pack script 'npm run pack:main && npm run pack:renderer'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the FormBuff package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error     npm run pack:main && npm run pack:renderer
24 error You can get information on how to open an issue for this project with:
24 error     npm bugs FormBuff
24 error Or if that isn't available, you can get their info via:
24 error     npm owner ls FormBuff
24 error There is likely additional logging output above.
25 verbose exit [ 2, true ]

最佳答案

我也遇到类似的问题。那是诀窍
https://github.com/SimulatedGREG/electron-vue/issues/200

关于webpack - 来自UglifyJs的renderer.js中的错误意外的标记点«(»,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43598037/

相关文章:

javascript - 将键和值打印到控制台

express - 如何在不同机器上的两个 Electron 应用程序之间进行交互

javascript - 使用从头开始构建的 webpack 的 react 应用程序未在 css 中加载图像

javascript - 在 Create React App 中设置导入的全局服务

javascript - 将数据发送到嵌套自定义输入组件的正确方法

css - 如何在 vue-bootstrap 表格模板中添加 css

ffmpeg - 使用 ffmpeg 在 webm 传输流中生成时间戳

javascript - 如何将 RxPy 数据流发送到前端 javascript

javascript - Vue 在用 webpack 编译时用注释替换 HTML

reactjs - 您当前正在使用 NODE_ENV === 'production' 之外的精简代码。这意味着您正在运行较慢的 Redux 开发版本