LoginSignup
3
2

More than 5 years have passed since last update.

browserifyを使っていて "fs.readFileSync is not a function" で怒られる

Posted at

Electron + gulp + browserify + babel + react みたいな環境で開発していたらハマりました。

メインプロセスとレンダラープロセス間で通信をしようと思い、
レンダラープロセス側のJSで Electron を require した。

すると、アプリケーションで以下のようなJSのエラーが発生。

fs.readFileSync is not a function

調べたところ、 browserify の require と npm のrequire がこんがらがってる。的な記事が見つかりました。

エラーで出ている fs モジュールは Electronモジュール内で require しているため、以下のような対処で解決した。

const electron = require 'electron';
↑ これを

const electrn = window.require 'electron';
↑ これに

詳細は後日追って...。

3
2
2

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
3
2