TypeError: Cannot assign to read only property 'toJSON' of object 'Error'
See original GitHub issue- Operating System version: macos 10.12.6, Node 9.5.0
- Firebase SDK version: 5.9.0
- Library version: 4.10.1
- Firebase Product: admin (auth, database, storage, etc)
[REQUIRED] Step 3: Describe the problem
Installed firebase-admin using instructions here: https://www.npmjs.com/package/firebase-admin Added firebase-admin to a module as instructed using:
var admin = require('firebase-admin');
in a module in a loopback node application. Application fails to start with the following error:
/Users/simon/Projects/APPICS/src/appics-backend/node_modules/firebase-admin/lib/utils/error.js:65
FirebaseError.prototype.toJSON = function () {
^
TypeError: Cannot assign to read only property 'toJSON' of object 'Error'
at /Users/abcdefg/Projects/APPICS/src/appics-backend/node_modules/firebase-admin/lib/utils/error.js:65:36
at Object.<anonymous> (/Users/simon/Projects/APPICS/src/appics-backend/node_modules/firebase-admin/lib/utils/error.js:72:2)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/abcdefg/Projects/APPICS/src/appics-backend/node_modules/firebase-admin/lib/firebase-namespace.js:21:15)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Module.require (module.js:604:17)
Waiting for the debugger to disconnect...
Process finished with exit code 1
Steps to reproduce:
What happened? How can we make the problem occur? This could be a description, log/console output, etc.
Relevant Code:
'use strict';
let admin = require("firebase-admin");
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Cannot assign to read only property 'toJSON' of object Error ...
Simple GET request with server status code 4xx, 5xxx throw error Uncaught TypeError: Cannot assign to read only property 'toJSON' of object ......
Read more >TypeError: Cannot assign to read only property - Stack Overflow
1 Answer 1 · something populates your array · for whatever reason, some or all properties of some or all of the objects...
Read more >TypeError: Cannot assign to read only property '_msgid' #2 - IBM
I get an error from the debug log: TypeError: Cannot assign to read only property '_msgid' of Number 10 is a high number....
Read more >TypeError: Attempted to assign to readonly property
In my code I was updating this JSON object, using the dot syntax (like data.name = 'Flavio' ) but I forgot to call...
Read more >Cannot assign to read only property 'X' of object ... - Reddit
Hi everyone, I am currently encountering an issue within my LWC. It was working before, but now it is throwing an error.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I used this command to figure out where
toJSON
is defined as a read only property onError
objectsIt was in my application code and not in any package. I just added
writable: true
toObject.assignProperty
call and that fixed the issue. This is the code after modification:@JuergenSimon, @reactor81 can you please run the grep command and check where is
toJSON
defined as a read only property?Hey @abdurahmanadilovic. Do you have a repro for this issue? Ideally something that just uses TypeScript and no other frameworks? The original reporter of this issue could only repro the problem on Loopback.