Dayroom
Good day! I've got errors `Uncaught TypeError: setting getter-only property "todo"` and `Uncaught TypeError: lib is undefined`. My assumption is that those errors appear when I created a new module for local storage API.
I moved specific functions of local storage to that module.
When the whole code stored in the global scope, app functions fine without issues. The syntax for named export/import is correct.
The code from storage module:
```
export let todo = JSON.parse(localStorage.getItem("todo-list"));
export function setLocalStorage() {
localStorage.setItem("todo-list", JSON.stringify(todo));
}
```
How it's imported:
```
import { todo, setLocalStorage } from "./modules/storageModule";
```
You can check my [repository here](https://github.com/DanMarkov/todo-app)
Top Answer
Anonymous 13630
It looks like the first error, `setting getter-only property "todo"`, happens because `todo` is declared with `let` and exported, making it read-only. Try exporting `todo` as a default object:
```
let todo = JSON.parse(localStorage.getItem("todo-list"));
export { todo };
export function setLocalStorage() {
localStorage.setItem("todo-list", JSON.stringify(todo));
}
```
For the `lib is undefined` error, ensure your import statements and paths are correct and consistent. Verify that `"./modules/storageModule"` is the right path, and double-check all referenced modules to be sure they are being imported correctly.