개발자
turborepo를 이용해서 electron react개발 후 배포하기 위해서 electron builder로 배포하려고 했습니다. 아래는 현재 구성되어있는 package.json파일입니다.
1{
2 "name": "desktop",
3 "version": "0.1.0",
4 "private": true,
5 "main": "./electron/main.js",
6 "homepage": "./",
7 "dependencies": {
8 "@tanstack/react-query": "^4.20.4",
9 "@tanstack/react-query-devtools": "^4.20.4",
10 "@testing-library/jest-dom": "^5.16.5",
11 "@testing-library/react": "^13.4.0",
12 "@testing-library/user-event": "^13.5.0",
13 "@types/jest": "^27.5.2",
14 "@types/node": "^16.18.10",
15 "@types/react": "^18.0.26",
16 "@types/react-dom": "^18.0.9",
17 "@types/styled-components": "^5.1.26",
18 "electron-is-dev": "^2.0.0",
19 "react": "^18.2.0",
20 "react-dom": "^18.2.0",
21 "react-router-dom": "^6.6.1",
22 "react-scripts": "5.0.1",
23 "recoil": "^0.7.6",
24 "styled-components": "^5.3.6",
25 "typescript": "^4.9.4",
26 "ui": "*",
27 "web-vitals": "^2.1.4"
28 },
29 "scripts": {
30 "start": "react-scripts start",
31 "react-build": "react-scripts build",
32 "react-test": "react-scripts test",
33 "react-eject": "react-scripts eject",
34 "start-renderer": "cross-env BROWSER=none yarn react-start",
35 "start-main": "electron .",
36 "trace": "electron --trace-warnings .",
37 "compile-main": "tsc ./electron/main.ts",
38 "start-main-after-renderer": "wait-on http://localhost:3000 && npm run start-main",
39 "dev": "yarn start && yarn start-main-after-renderer",
40 "pack": "yarn compile-main && yarn react-build && electron-builder --dir",
41 "build": "yarn compile-main && npm run react-build && electron-builder build",
42 "build:osx": "yarn build -- --mac",
43 "build:linux": "yarn build -- --linux",
44 "build:win": "yarn run build -- --win",
45 "predist": "npm run compile-main"
46 },
47 "eslintConfig": {
48 "extends": [
49 "react-app",
50 "react-app/jest"
51 ]
52 },
53 "browserslist": {
54 "production": [
55 ">0.2%",
56 "not dead",
57 "not op_mini all"
58 ],
59 "development": [
60 "last 1 chrome version",
61 "last 1 firefox version",
62 "last 1 safari version"
63 ]
64 },
65 "devDependencies": {
66 "concurrently": "^7.6.0",
67 "cross-env": "^7.0.3",
68 "electron": "^22.0.0",
69 "electron-builder": "^23.6.0",
70 "eslint-config-custom": "*",
71 "tsconfig": "*",
72 "wait-on": "^7.0.1"
73 },
74 "build": {
75 "appId": "INFO",
76 "productName": "INFO",
77 "win": {
78 "target": [
79 "nsis"
80 ],
81 "icon": "icon.ico"
82 },
83 "nsis": {
84 "oneClick": true,
85 "installerIcon": "icon.ico",
86 "uninstallerIcon": "icon.ico",
87 "uninstallDisplayName": "info-uninstaller",
88 "license": "license.md"
89 },
90 "linux": {
91 "target": [
92 "snap",
93 "AppImage",
94 "deb",
95 "rpm"
96 ]
97 },
98 "files": [
99 "dist/",
100 "node_modules/",
101 "package.json"
102 ],
103 "publish": [
104 {
105 "provider": "github"
106 }
107 ]
108 }
109}
답변 2
익명
작성자
2023년 04월 14일
• electron-builder version=23.6.0 os=21.6.0 • loaded configuration file=package.json ("build" field) • public/electron.js not found. Please see https://medium.com/@kitze/%EF%B8%8F-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3 • loaded parent configuration preset=react-cra • description is missed in the package.json appPackageFile=/Users/gimjingeon/Desktop/project/INFO_V2_FrontEnd/apps/desktop/package.json • author is missed in the package.json appPackageFile=/Users/gimjingeon/Desktop/project/INFO_V2_FrontEnd/apps/desktop/package.json ⨯ Cannot compute electron version from installed node modules - none of the possible electron modules are installed and version ("^22.0.0") is not fixed in project. See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. message는 이렇게 되어있습니다.
진성주
무신사 프론트엔드 개발자 • 2023년 04월 14일
음 메세지에 해결에 대한 실마리가 보입니다. - electron-builder version=23.6.0 os=21.6.0 - loaded configuration file=package.json("build" field) - public/electron.js를 찾을 수 없습니다. https://medium.com/@kitze/%EF%B8%8F-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3를 참조하세요. - 로드된 부모 구성 preset=react-cra - package.json에 설명이 누락됨 appPackageFile=/Users/gimjingeon/Desktop/project/INFO_V2_FrontEnd/apps/desktop/package.json - package.json에 작성자가 누락됨 appPackageFile=/Users/gimjingeon/Desktop/project/INFO_V2_FrontEnd/apps/desktop/package.json ⨯ 설치된 노드 모듈에서 전자 버전을 계산할 수 없음 - 가능한 전자 모듈이 설치되어 있지 않고 프로젝트에서 버전("^22.0.0")이 고정되어 있지 않습니다. https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246 참조
익명
작성자
2023년 04월 15일
github issue에서 전에 yarn install --production이랑 다른 것도 살펴봤었는데 cli arg와 electron-version 지정하는걸 놓쳤었네요.. 해결해주기 위해 도와주셔서 감사합니다.
프로젝트에서 Electron 버전을 결정하는 데 문제가 발생한 것으로 보입니다. 이 문제를 해결하려면 다음 단계를 수행하세요. 1. Electron 설치 확인 먼저, 프로젝트에서 Electron이 올바르게 설치되어 있는지 확인하세요. ' package.json ' 파일에서 ' electron ' 패키지가 ' dependencies ' 또는 ' devDependencies ' 섹션에 있는지 확인합니다. 이 경우 ' electron '이 이미 ' devDependencies ' 섹션에 있는 것을 확인할 수 있습니다. 2. package.json 수정 ' electron-builder '가 Electron 버전을 계산할 수 있도록 ' package.json '의 ' electron ' 버전을 고정값으로 설정하세요. ' devDependencies ' 섹션에서 ' electron ' 버전을 ' ^22.0.0 '에서 ' 22.0.0 '으로 변경합니다. 3. node_modules 재설치 변경 사항을 적용한 후, 프로젝트에서 ' node_modules ' 폴더를 삭제하고 다시 설치하세요. 4. 다시 빌드 시도 이제 ' yarn build '를 실행하여 프로젝트를 다시 빌드해 보세요. 이 문제가 해결되어야 합니다. 위 단계를 완료한 후에도 문제가 지속되면 프로젝트 폴더에서 ' electron ' 패키지가 올바르게 설치되어 있는지 확인하거나, 필요한 경우 다시 설치하세요.
1#2
2"devDependencies": {
3 ...
4 "electron": "22.0.0",
5 ...
6},
7
8#3
9rm -rf node_modules
10yarn install
11
12#4
13yarn add electron@22.0.0 --dev
커리어리 AI 봇의 답변을 평가해 주세요!
지금 가입하면 모든 질문의 답변을 볼 수 있어요!
현직자들의 명쾌한 답변을 얻을 수 있어요.
이미 회원이신가요?
지금 가입하면 모든 질문의 답변을 볼 수 있어요!