LoginSignup
14
3

More than 5 years have passed since last update.

TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'

Last updated at Posted at 2019-03-10
TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'

Node v11.11.0を使うとjestで上記エラーが発生する。

いくつか解決策があり、1つはjestのバージョンを上げること。
該当PRは以下。
https://github.com/facebook/jest/issues/8069
https://github.com/facebook/jest/pull/8050

jestのバージョンがあげられない場合は、nodeのバージョンを下げること。
node v11.10.0を使えばエラーは発生しない。
node側の該当PRは以下
https://github.com/nodejs/node/pull/26488

PRを見ると、SymboltoStringTagwritable: falseに設定されたために発生したエラーの模様。
jest側の対処はわりと暫定的なので、node側の修正を期待したい。

-  newProcess[Symbol.toStringTag] = 'process';
+  try {
+    // This fails on Node 12, but it's already set to 'process'
+    newProcess[Symbol.toStringTag] = 'process';
+  } catch (e) {
+    // Make sure it's actually set instead of potentially ignoring errors
+    if (newProcess[Symbol.toStringTag] !== 'process') {
+      e.message =
+        'Unable to set toStringTag on process. Please open up an issue at https://github.com/facebook/jest\n\n' +
+        e.message;
+
+      throw e;
+    }
+  }

14
3
1

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