LoginSignup
4
3

More than 3 years have passed since last update.

Uncaught TypeError: fs.existsSync is not a functionのエラー解決

Posted at

状況

Windowsアップデートついでにnode.jsとかモジュールをアップデートしたらelectronでエラーが出るようになった。

Uncaught TypeError: fs.existsSync is not a function'

err.png

環境

  • windows 10 Pro Insider Preview 2004 (20150.1000)
  • node v14.4.0
  • Electron 9.0.4
  • Vue.js 2.6.11
  • Vuex 3.4.0
  • vuetify 2.2.11

原因

ipcRendererが原因のもよう。
レンダラープロセスがノードモジュールにアクセスしようとして失敗しているみたい。

解決方法

vue.config.jsファイルに下記を追記したら動いてくれた。

module.exports = {
  transpileDependencies: [
    'vuetify'
  ],
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true
    }
  }
}

これでレンダラープロセスがノードモジュールにアクセスできるようになりエラーが回避できる。
ただし脆弱性になりうるので、公開するアプリなどでは注意が必要とのこと。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3