WEB/Electron

[Electron] electron 최신 버전으로 업그레이드

S0PH1A 2019. 5. 4. 11:16
반응형

[Electron] electron 버전 업그레이드


2018년에 설치 했을 때 버전이 1.X 버전이었는데, 

어느새 5.0.0 버전이 나왔다.

 

electron 4.X 버전 부터인가 node 10버전 이상 이용하기 때문에 ES6를 babel을 사용하지 않고도 대부분의 명령어를 사용할 수 있다고 한다.

 

* 여기서 릴리즈 버전을 확인할 수 있다.

 

electron 최신 버전으로 업그레이드 명령어는 다음과 같다.

설치하는데 시간이 좀 걸린다.

$ npm install electron@latest -g
C:\WINDOWS\system32>npm install electron@latest -g
C:\Users\itinerant\AppData\Roaming\npm\electron -> C:\Users\itinerant\AppData\Roaming\npm\node_modules\electron\cli.js

> electron@5.0.0 postinstall C:\Users\itinerant\AppData\Roaming\npm\node_modules\electron
> node install.js

Downloading tmp-66320-1-SHASUMS256.txt-5.0.0
[============================================>] 100.0% of 4.74 kB (4.74 kB/s)
+ electron@5.0.0
added 145 packages from 141 contributors in 37.426s

 


 

electron 업그레이드 후 require is not defined 오류가 발생할 수 있다. 

 

예를 들어, jQuery ($) 사용을 위해 require 를 사용한 경우 이전 버전에서는 문제없이 작동했으나,

업그레이드 후 아래와 같이 require가 선언되어 있지 않다는 오류가 발생했다.

require 오류

 

Main(서버)에서 BrowserWindow를 생성할 때 옵션들 중 webPreferences nodeIntegration true 로 해서 추가해 주면 된다.

nodeIntegration 옵션은 node를 통합할 지 여부를 선택하는 옵션이며, 기본 값은 false이다.

true 로 변경해줌으로써 클라이언트 웹 페이지에서 node 를 사용할 수 있게 한다.

옵션에 대한 자세한 설명은 여기서 확인이 가능하다.

new BrowserWindow({
	...
    webPreferences: {
    	nodeIntegration : true
    },
	...
})

 

반응형