1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Firebase emulators:exec でjestが実行できないときに

Posted at

Firebase firestoreを使っていると,firestore rulesのテストを書きたくなるものですよね.

しかし,いざテストを書きはじめて,

firebase emulators:exec --only firestore "yarn test"

動作確認しようとすると,

TypeError: _gracefulFs(...).realpathSync.native is not a function
    at tryRealpath (/Users/tom/Work/src/github.com/nicecab/memcpy/firebase/rules/node_modules/jest-util/build/tryRealpath.js:26:39)
    at getCacheDirectory (/Users/tom/Work/src/github.com/nicecab/memcpy/firebase/rules/node_modules/jest-config/build/getCacheDirectory.js:89:33)
    at Object.<anonymous> (/Users/tom/Work/src/github.com/nicecab/memcpy/firebase/rules/node_modules/jest-config/build/Defaults.js:49:50)
    at Module._compile (internal/modules/cjs/loader.js:1136:30)
    at Module._compile (pkg/prelude/bootstrap.js:1394:32)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
    at Module.load (internal/modules/cjs/loader.js:984:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1024:19)
    at Module.require (pkg/prelude/bootstrap.js:1338:31)
error Command failed with exit code 1.

が出てしまって,テストが実行できないという事態に遭遇することがあります.

TypeError: _gracefulFs(...).realpathSync.native is not a function · Issue #10012 · facebook/jest

のようにみんな困っていて,その対策もなんというか,人それぞれ環境によって異なる印象を受けます.

そんな中,さらに,個別の環境でうまくいったという報告を一つ追加する程度の意味合いしかないのですが,私の環境では,firebase-toolsをauto install scriptでいれていました(だって,それが,Firebase CLI referenceの推奨のように見えるもの).

ところが,上記エラーをいかんともしがたく,四苦八苦しながら,いろいろ情報を漁っていたところ,

https://github.com/firebase/firebase-tools/issues/1868#issuecomment-566686331 にて,

Strangely this problem was fixed by removing the firebase-cli binary I installed with the auto-install script (curl -sL firebase.tools | bash) and reinstalling firebase-cli with Homebrew.

というコメントを発見.

もしやと思い,auto install scriptでインストールしたfirebaseバイナリを

% rm -f /usr/local/bin/firebase 

で削除し,npm/yarn globalでいれてみたら,

% yarn global add firebase-tools

なんと上記エラーを解消することができました.

原因はよくわからないですが,auto install scriptでインストールされるfirebaseバイナリ内に,古いバージョンのnode runtimeが埋め込まれていたりするのですかね...

同様の事象に悩まれた方のために,記録として残しておきます.

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?