Module not found? Your AI invented a file that doesn't exist
If you're building with AI and you hit this: Error: Cannot find module './utils/formatDate' Your code isn't broken. Your AI just lied by omission. It wrote an import for a helper file it planned to create — then forgot to create it. That's vibe-coding bug #1, and it stops more beginners than almost anything else. What it actually means Your app is trying to load a file or package that isn't…
If you're using artificial intelligence to build your application and you encounter an error message that reads: "Cannot find module './utils/formatDate'," it doesn't necessarily mean that your code is flawed. In fact, what your AI-powered tool may have done is omitted the creation of an import for a helper file it intended to make, and then neglected to generate the file altogether. This common mistake, dubbed "vibe-coding bug #1," is a stumbling block for many novices in the world of coding.
To put it simply, the issue arises when your application attempts to load a file or package that simply isn't present. The problem could stem from the file never being created, the path being incorrectly specified (especially regarding capitalization), or the package not having been installed via npm.
To remedy this issue in just a couple of minutes, start by verifying the existence of the file referenced in the path. If the issue lies with an npm package, simply run the command "npm install package-name" to install it. Should the file be missing, it's crucial not to delete the import statement in your code. Instead, instruct your AI to generate the missing file. The required functions should be included in the file, or you may need to correct the import path to accurately reflect the location of the actual file.
It's worth noting that this error pattern is among five that we instruct in the Debug Clinic at Last20 Academy, offering straightforward English explanations for the errors often faced by AI-built applications. The complimentary Prompt Starter Kit covers the prompts side of things. So, the next time you come across this error, remember the steps outlined above to resolve the issue swiftly and efficiently.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to