electron 对现有的基于react js的项目执行电子js / builder时出错

31moq8wy  于 2022-12-08  发布在  Electron
关注(0)|答案(2)|浏览(173)

我有一个运行React js的全功能项目,后端是Rails
计划使用electron.js构建桌面应用程序
它在dev上运行得很完美

PORT=3001 concurrently \"cross-env BROWSER=none yarn react-start\" \"wait-on http://localhost:3001 && electron .\

当我运行Yarn运行电子生成器-我得到以下错误

• electron-builder  version=22.10.5 os=20.3.0
  • loaded configuration  file=package.json ("build" field)
  • loaded parent configuration  preset=react-cra
  • Specified application directory equals to project dir — superfluous or wrong configuration  appDirectory=.
  • description is missed in the package.json  appPackageFile=/Users/admin/Dev/project/frontend/package.json
  • writing effective config  file=out/builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=canvas@2.7.0, fsevents@1.2.13, node-sass@4.14.1 platform=darwin arch=x64
  • rebuilding native dependency  name=canvas version=2.7.0
  • rebuilding native dependency  name=fsevents version=1.2.13
  • rebuilding native dependency  name=node-sass version=4.14.1
  • packaging       platform=darwin arch=x64 electron=11.4.2 appOutDir=out/mac
  • Unpacking electron zip  zipPath=undefined
  ⨯ editions-autoloader-none-broadened: Unable to determine a suitable edition, even after broadening.  stackTrace=
Error: editions-autoloader-none-broadened: Unable to determine a suitable edition, even after broadening.
at new Errlop (/Users/admin/Dev/project/frontend/node_modules/errlop/edition-es5/index.js:61:18)
at Object.errtion (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/util.js:23:14)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:317:21)
at solicitEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/app-builder-lib/electron-osx-sign/util.js:135:22)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
↳ Error: editions-autoloader-none-suitable: Unable to determine a suitable edition, as none were suitable.
at new Errlop (/Users/admin/Dev/project/frontend/node_modules/errlop/edition-es5/index.js:61:18)
at Object.errtion (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/util.js:23:14)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:327:19)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:312:12)
at solicitEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/app-builder-lib/electron-osx-sign/util.js:135:22)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
↳ Error: editions-autoloader-edition-incompatible: editions-autoloader-edition-incompatible: The edition [TypeScript source code made to be compatible with Deno] is not compatible with this environment.
at new Errlop (/Users/admin/Dev/project/frontend/node_modules/errlop/edition-es5/index.js:61:18)
at Object.errtion (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/util.js:23:14)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:301:25)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:312:12)
at solicitEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/app-builder-lib/electron-osx-sign/util.js:135:22)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
↳ Error: editions-autoloader-edition-incompatible: editions-autoloader-edition-incompatible: The edition [TypeScript compiled against ES2019 for Node.js 12 || 14 || 15 with Import for modules] is not compatible with this environment.
at new Errlop (/Users/admin/Dev/project/frontend/node_modules/errlop/edition-es5/index.js:61:18)
at Object.errtion (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/util.js:23:14)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:301:25)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:312:12)
at solicitEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/app-builder-lib/electron-osx-sign/util.js:135:22)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
↳ Error: editions-autoloader-edition-incompatible: editions-autoloader-edition-incompatible: The edition [TypeScript compiled against ES2019 for Node.js 10 || 12 || 14 || 15 with Require for modules] is not compatible with this environment.
at new Errlop (/Users/admin/Dev/project/frontend/node_modules/errlop/edition-es5/index.js:61:18)
at Object.errtion (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/util.js:23:14)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:301:25)
at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:312:12)
at solicitEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/app-builder-lib/electron-osx-sign/util.js:135:22)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)

at determineEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:312:12)
at solicitEdition (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:350:16)
at Object.requirePackage (/Users/admin/Dev/project/frontend/node_modules/editions/edition-es5/index.js:364:9)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/istextorbinary/index.cjs:4:38)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/admin/Dev/project/frontend/node_modules/app-builder-lib/electron-osx-sign/util.js:135:22)

我使用的是OSX - Big Sur
节点- v13.14.0Yarn- 1.22.10和xcode 12.4
我以为这个问题只是在osx上。我在windows build yarn run electron-builder -m上遇到了一些其他问题

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:697:50: note: 'remove_cv' declared here
    template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                     ^
    1 error generated.
    make: *** [Release/obj.target/binding/src/binding.o] Error 1
    gyp ERR! build error 
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack     at ChildProcess.onExit (/Users/admin/Dev/project/frontend/node_modules/node-sass/node_modules/node-gyp/lib/build.js:262:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    gyp ERR! System Darwin 20.3.0
    gyp ERR! command "/Users/admin/.nvm/versions/node/v13.14.0/bin/node" "/Users/admin/Dev/project/frontend/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    gyp ERR! cwd /Users/admin/Dev/project/frontend/node_modules/node-sass
    gyp ERR! node -v v13.14.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok 
    Build failed with error code: 1
    error Command failed with exit code 1.
    
                    command=/Users/admin/.nvm/versions/node/v13.14.0/bin/node /usr/local/lib/node_modules/yarn/bin/yarn.js run install
                    workingDir=/Users/admin/Dev/project/frontend/node_modules/node-sass
error Command failed with exit code 1.
polkgigr

polkgigr1#

删除node_modules并再次运行npm i。之后应该可以运行。
要在命令行中删除node_modules,请用途:rm -R node_modules -f .
这对我很有效,在那之后没有错误地构建。

xzabzqsa

xzabzqsa2#

我有同样的问题!这是一个问题版本NodeJS,我使用的是v16.16.0,我做了v16.15.O降级。按照降级节点后的步骤:

  • 删除节点模块
  • 删除包-lock.json
  • NPN安装

现在是工作和建设。

相关问题