CodeNewbie Community 🌱

Abdulrahman Noble
Abdulrahman Noble

Posted on

Webpack can't recognize modules

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));
  }

Enter fullscreen mode Exit fullscreen mode

How it's imported:

import { todo, setLocalStorage } from "./modules/storageModule";
Enter fullscreen mode Exit fullscreen mode

You can check my repository here

Top comments (0)