Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Webpack can't recognize modules
Post
Webpack can't recognize modules
I've got errors
Uncaught TypeError: setting getter-only property "todo"
andUncaught TypeError: lib is undefined
.
I assume that those errors appeared when I created a new module for local storage API.
I moved specific functions of local storage to that module. When the whole code is stored in the global scope, the app functions 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
1 comment thread