Node.js global variable error 'Uncaught TypeError: "object" is read-only'

15 Views Asked by At

I am trying to check if 'object' is saved in Local storage, and if it is then assign a global variable the object in a separate file, however, in the console it is saying Uncaught TypeError: "object" is read-only (local-storage already contains information)...

Here is my code and files

object.mjs

export let object = createObject();
function createObject()
    return {
        'name': undefined,
        'age': 0,
        'score': 0,
    }
}

app.js

import { object } from "./lib/object.mjs";
object = JSON.parse(localStorage.getItem('Object'));
0

There are 0 best solutions below