我正在尝试使用React(CRA)和Electron构建桌面应用程序,但是对于如何将其打包并编译为Mac的.app
文件一无所知。我一直在关注this tutorial(使用npm而不是yarn),并遇到以下错误:
> build —-c.extraMetadata.main=build/electron.js
/Users/user/Desktop/React Stuff/my-app/node_modules/read-config-file/out/main.js:92
async function findAndReadConfig(request) {
^^^^^^^^
SyntaxError: Unexpected token function
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 _readConfigFile (/Users/user/Desktop/React Stuff/my-app/node_modules/electron-builder/src/cli/cli.ts:10:1)
at Object.args [as handler] (/Users/user/Desktop/React Stuff/my-app/node_modules/electron-builder/src/cli/cli.ts:42:1)
at Object.runCommand (/Users/user/Desktop/React Stuff/my-app/node_modules/electron-builder/node_modules/yargs/lib/command.js:237:44)
at Object.parseArgs [as _parseArgs] (/Users/user/Desktop/React Stuff/my-app/node_modules/electron-builder/node_modules/yargs/yargs.js:1068:28)
at Object.get [as argv] (/Users/user/Desktop/React Stuff/my-app/node_modules/electron-builder/node_modules/yargs/yargs.js:1000:21)
at Object.<anonymous> (/Users/user/Desktop/React Stuff/my-app/node_modules/electron-builder/src/cli/cli.ts:25:28)
at Module._compile (module.js:570:32)
有什么想法吗?我想继续使用npm而不是切换到yarn,但是,如果那是唯一的解决方案,那就好了。