dev/개인 프로젝트

Electron Uncaught TypeError: Cannot read property 'fn' of undefined 에러 해결

jeongsu 2020. 3. 1. 11:59

웹서버에선 잘동작하는데

 

Electron 으로 시작하면 위의 에러가 뜨는 알수없는 현상이 있었다.

 

실제로 콘솔창에

 

$.fn의 변수를 보니

 

웹서버에선 정상적으로 있었지만, Electron에선 없었다.

 

 

 

이런 현상은 나만 격는게 아니였고, StackoverFlow에 해결방법을 찾았다.

 

1
2
3
4
5
6
7
8
//Before
 
 <script src="./plugins/jquery/jquery.min.js"></script> 
 
// After
  <script>
      window.$ = window.jQuery = require('jquery');
    </script>

 

npm install jquery 한뒤 위의 방법으로 스크립트를 불러오면 해결된다.

 

아래는 StackoverFlow 주소이다

 

https://stackoverflow.com/questions/50541298/uncaught-typeerror-cannot-read-property-fn-of-undefined-electron-2-angular?fbclid=IwAR0sr3a-FXRkoRFAyc57M4Yf6ArNuhiQdTg9LY5_D2_OVk-jUEAQXH9XQpk

 

Uncaught TypeError: Cannot read property 'fn' of undefined, electron 2, angular 6?

I'm using Angular 6.0.3, electronjs 2.0.2 with the following package.json { "name": "test", "version": "1.0.0", "license": "MIT", "main": "electron-main.js", "author": { "name": "Moh...

stackoverflow.com