Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Webpack UglifyJs意外标记punc«中的renderer.js出错;(»;_Webpack_Vue.js_Electron_Uglifyjs - Fatal编程技术网

Webpack UglifyJs意外标记punc«中的renderer.js出错;(»;

Webpack UglifyJs意外标记punc«中的renderer.js出错;(»;,webpack,vue.js,electron,uglifyjs,Webpack,Vue.js,Electron,Uglifyjs,版本:网页2.3.3 你好 我正在尝试使用Vuejs构建我的第一个Electron应用程序。在我开始打包应用程序之前,一切似乎都很顺利 当我运行npm-run-dev时,一切正常 但是,当我运行npm build:darwin时,我得到以下错误 UglifyJs中renderer.js中的错误 意外的令牌punc«(»,预期的punc«:»[renderer.js:26813,14] 但是,当我运行应用程序时,它最终会被编译成死亡的白色屏幕 据我所知,这可能是因为Uglifyjs不编译ES6,但

版本:网页2.3.3

你好

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

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

但是,当我运行
npm build:darwin
时,我得到以下错误

UglifyJs中renderer.js中的
错误
意外的令牌punc«(»,预期的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 ]
0信息如果它以ok结尾,它就工作了
1 verbose cli['/usr/local/ceral/node/7.9.0/bin/node',
1个详细cli'/usr/local/bin/npm',
1详细cli“运行”,
1详细cli“包”]
2信息使用npm@4.2.0
3信息使用node@v7.9.0
4详细的运行脚本['prepack','pack','postpack']
5信息生命周期FormBuff@0.0.0~prepack:FormBuff@0.0.0
6愚蠢的生命周期FormBuff@0.0.0~prepack:没有用于prepack的脚本,正在继续
7信息生命周期FormBuff@0.0.0~pack:FormBuff@0.0.0
8详细的生命周期FormBuff@0.0.0~pack:lifecycle中的不安全烫发正确
9详细的生命周期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/thread/link/node_modules/.bin:/Users/admin/.config/thread/link/node_-modules/.bin:/usr/local/cillar/warn/0.23.2/libexec/bin/node gyp-bin:/Users/admin/.rbenv/shimmers:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/admin/.composer/vendor/bin:/Users/admin/go/bin
10详细的生命周期FormBuff@0.0.0~pack:CWD:/Users/admin/Code/electron/formbuff
11愚蠢的生命周期FormBuff@0.0.0~pack:Args:['-c',npm运行包:主(&npm运行包:渲染器']
12愚蠢的生命周期FormBuff@0.0.0~pack:Returned:code:2信号:null
13信息生命周期FormBuff@0.0.0~pack:无法执行包脚本
14详细堆栈错误:FormBuff@0.0.0pack:`npm run pack:main&&npm run pack:renderer`
14详细堆栈退出状态2
14 EventEmitter上的详细堆栈。(/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 emitTwo上的详细堆栈(events.js:106:13)
14 EventEmitter.emit上的详细堆栈(events.js:194:7)
14子进程上的详细堆栈。(/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 emitTwo上的详细堆栈(events.js:106:13)
14 ChildProcess.emit上的详细堆栈(events.js:194:7)
14 maybeClose的详细堆栈(internal/child_process.js:899:16)
14 Process.ChildProcess.\u handle.onexit处的详细堆栈(internal/child\u Process.js:226:5)
15详细的pkgidFormBuff@0.0.0
16详细的cwd/Users/admin/Code/electron/formbuff
17达尔文16.5.0
18错误argv“/usr/local/ceral/node/7.9.0/bin/node”“/usr/local/bin/npm”“运行”“包”
19错误节点v7.9.0
20错误npm v4.2.0
21错误代码ELIFECYCLE
22错误2
23错误FormBuff@0.0.0pack:`npm run pack:main&&npm run pack:renderer`
23错误退出状态2
24错误发生在FormBuff@0.0.0包脚本“npm运行包:主(&npm运行包:渲染器)”。
24错误确保已安装最新版本的node.js和npm。
24错误如果您这样做,这很可能是FormBuff包的问题,
24错误与npm本身无关。
24错误告诉作者此操作在您的系统上失败:
24错误npm运行包:主和npm运行包:渲染器
24错误您可以通过以下方式获取有关如何打开此项目问题的信息:
24错误npm错误FormBuff
24错误或如果不可用,您可以通过以下方式获取他们的信息:
24错误npm所有者ls FormBuff
24错误上面可能有其他日志输出。
25详细退出[2,正确]

我也遇到了类似的问题。这就是诀窍
我也遇到了类似的问题。这就是诀窍

您可以尝试安装
uglify
版本,它名为
uglify es
,它是:

用于ES6的JavaScript解析器、mangler/compressor和beautifier工具包+

就我而言,我已经安装了
babel
插件来处理这个问题。 如果要尝试,请执行以下操作:

将此添加到您的
包.json

"babel-core": "latest",
"babel-loader": "latest",
"babel-plugin-transform-async-to-generator": "latest",
"babel-plugin-transform-runtime": "latest",
"babel-preset-es2015": "latest",
"babel-runtime": "latest"
将您的
webpack.config
文件设置为类似(例如,这是我的):

.babelrc
文件设置为:

{
    "presets": ["es2015"],
    "plugins": ["transform-runtime", "transform-async-to-generator"]
}
希望它有帮助:)

您可以尝试安装
uglify
的版本,它名为
uglify es
,它是:

用于ES6的JavaScript解析器、mangler/compressor和beautifier工具包+

就我而言,我已经安装了
babel
插件来处理这个问题。 如果要尝试,请执行以下操作:

将此添加到您的
包.json

"babel-core": "latest",
"babel-loader": "latest",
"babel-plugin-transform-async-to-generator": "latest",
"babel-plugin-transform-runtime": "latest",
"babel-preset-es2015": "latest",
"babel-runtime": "latest"
将您的
webpack.config
文件设置为类似(例如,这是我的):

.babelrc
文件设置为:

{
    "presets": ["es2015"],
    "plugins": ["transform-runtime", "transform-async-to-generator"]
}

希望有帮助:)

为什么要在电子应用程序中使用网页包?您可以使用electron自动编译和构建所有单文件组件(如果您正在使用它们)@BertEvans说实话,我在谷歌上搜索了一些electron和vuejs的样板文件,发现了这个——我用它构建了一些其他东西(尽管是小应用程序),我没有问题。我会看看你的链接,看起来不错!谢谢为什么要在电子应用程序中使用网页包?您可以使用electron自动编译和构建所有单文件组件(如果您正在使用它们)@BertEvans说实话,我在谷歌上搜索了一些electron和vuejs的样板文件,发现了这个——我用它构建了一些其他东西(尽管是小应用程序),但我没有p