0

我正在使用electron-react-boilerplate创建一个桌面应用程序。我正在使用纱线包管理器。

我在 4 个月前编译了这个应用程序。但是现在无法编译。

当我编写yarn package命令时,它显示此错误:

yarn run v1.21.1
$ yarn build && electron-builder build --publish never
$ concurrently "yarn build-main" "yarn build-renderer"
$ cross-env NODE_ENV=production webpack --config ./configs/webpack.config.main.prod.babel.js --colors
$ cross-env NODE_ENV=production webpack --config ./configs/webpack.config.renderer.prod.babel.js --colors
[0] 
[0] WARNING: We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.
[0]
[0] You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:
[0]
[0]   npm install --save core-js@2    npm install --save core-js@3
[0]   yarn add core-js@2              yarn add core-js@3
[0]
[1]
[1] WARNING: We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.
[1]
[1] You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:
[1]
[1]   npm install --save core-js@2    npm install --save core-js@3
[1]   yarn add core-js@2              yarn add core-js@3
[1]
[0] Hash: bd31df9321aa201ea119
[0] Version: webpack 4.41.6
[0] Time: 630ms
[0] Built at: 2020-02-23 21:50:09
[0]                  Asset      Size  Chunks                   Chunk Names
[0]     ./app/main.prod.js  2.19 KiB       0  [emitted]        main
[0] ./app/main.prod.js.map  3.33 KiB       0  [emitted] [dev]  main
[0] Entrypoint main = ./app/main.prod.js ./app/main.prod.js.map
[0] [./app/main.dev.js] 2.99 KiB {0} [built]
[0] [electron] external "electron" 42 bytes {0} [built]
[0] [path] external "path" 42 bytes {0} [built]
[0] [url] external "url" 42 bytes {0} [built]
[0] yarn build-main exited with code 0
[1] Hash: 71987f1d3c60720a4ec4
[1] Version: webpack 4.41.6
[1] Time: 493ms
[1] Built at: 2020-02-23 21:50:10
[1]                Asset      Size  Chunks                   Chunk Names
[1]     renderer.prod.js     2 KiB       0  [emitted]        main
[1] renderer.prod.js.map  8.96 KiB       0  [emitted] [dev]  main
[1] Entrypoint main = renderer.prod.js renderer.prod.js.map
[1] [./app/index.js] 2.64 KiB {0} [built]
[1] [electron] external "electron" 42 bytes {0} [built]
[1] [path] external "path" 42 bytes {0} [built]
[1] [url] external "url" 42 bytes {0} [built]
[1] yarn build-renderer exited with code 0
  • electron-builder version=20.44.4
  • loaded configuration file=package.json ("build" field)
  • writing effective config file=release\builder-effective-config.yaml
SyntaxError: Unexpected token  in JSON at position 0
SyntaxError: Unexpected token  in JSON at position 0
    at JSON.parse (<anonymous>)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:55:22
    at tryCatcher (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\promise.js:729:18)
    at Promise._fulfill (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\promise.js:673:18)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\bluebird\js\release\nodeback.js:42:21
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\graceful-fs\graceful-fs.js:115:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
From previous event:
    at readJson (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:55:6)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:224:61
    at Generator.next (<anonymous>)
    at callback (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\graceful-fs\polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:159:5)
From previous event:
    at Collector.readChildPackage (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:206:90)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:191:69
From previous event:
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:191:40
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:439:21)
From previous event:
    at Collector.readInstalled (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:170:91)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:78:16
    at Generator.next (<anonymous>)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\graceful-fs\graceful-fs.js:115:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
From previous event:
    at Collector.collect (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:76:28)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\packageDependencies.ts:47:44
    at Generator.next (<anonymous>)
    at _getProductionDependencies (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\packageDependencies.js:92:37)
    at getProductionDependencies (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\packageDependencies.js:83:37)
    at Lazy.<anonymous> (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:138:24)
    at Generator.next (<anonymous>)
    at Lazy.get value [as value] (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\lazy-val\src\main.ts:18:25)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\yarn.js:166:90
From previous event:
    at _getProductionDependencies (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\packageDependencies.js:92:37)
    at getProductionDependencies (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\packageDependencies.js:83:37)
    at Lazy.<anonymous> (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:138:24)
    at Generator.next (<anonymous>)
From previous event:
    at Lazy.get value [as value] (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\lazy-val\src\main.ts:18:25)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\yarn.js:166:90
    at Generator.next (<anonymous>)
From previous event:
    at _rebuild (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\yarn.ts:179:5)
    at rebuild (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\yarn.js:163:19)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\util\yarn.ts:20:11
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:439:21)
From previous event:
    at _installOrRebuild (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\yarn.js:71:28)
    at installOrRebuild (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\out\util\yarn.js:55:28)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:509:13
    at Generator.next (<anonymous>)
From previous event:
    at Packager.installAppDependencies (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:470:70)    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:420:20
    at Generator.next (<anonymous>)
From previous event:
    at Packager.doBuild (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:396:24)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:366:57
    at Generator.next (<anonymous>)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\graceful-fs\graceful-fs.js:136:16
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\graceful-fs\graceful-fs.js:57:14
    at FSReqCallback.oncomplete (fs.js:146:23)
From previous event:
    at Packager._build (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:335:133)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:331:23
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:439:21)
From previous event:
    at Packager.build (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\packager.ts:288:14)
    at build (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\app-builder-lib\src\index.ts:59:28)
    at build (E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\electron-builder\src\builder.ts:228:10)
    at E:\Programming\htdocs\NodeJS\palettenzettel-4\node_modules\electron-builder\src\cli\cli.ts:49:19
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

这是yarn package命令脚本:

"package": "yarn build && electron-builder build --publish never",
4

1 回答 1

0

所以你正在使用旧版本electron-builder更新到最新版本使用并重yarn add electron-builder@latestyarn package

于 2020-03-01T11:33:35.293 回答