跟随React Workshop实操遇Module not found报错求助
Hey there! Let's work through fixing that annoying module error you're hitting while following your React workshop (you're at page 17/27, right?). Here are the key checks to resolve this:
Double-check the file's existence and location
First, make sure you actually have anAppRoutes.js(orAppRoutes.jsx, depending on your project's file extension setup) in the same folder as the file trying to import it. For example, if you're importing fromsrc/App.js, theAppRoutesfile needs to live directly insrc/too. Also remember: StackBlitz uses a case-sensitive file system—soapproutes.jswon't match./AppRoutesif the tutorial uses camel casing.Verify your import statement matches the export type
If the tutorial uses a default export forAppRoutes(likeexport default AppRoutes;at the bottom of the component file), your import should look like this:import AppRoutes from './AppRoutes';If it's a named export, you'll need curly braces:
import { AppRoutes } from './AppRoutes';Most workshop tutorials use default exports for components like this, so start with the first format.
Confirm you've created the
AppRoutesfile as per the tutorial
Since you're on page 17, it's possible the tutorial is walking you through creating this file right now—maybe you accidentally skipped that step! Flip back to page 17 and follow the instructions to create theAppRoutesfile with the exact code from the workshop.Restart your StackBlitz project
Sometimes StackBlitz's cache can throw false module not found errors. Hit the "Restart" button in the top-right corner of the editor to refresh the project and clear any cached state.
内容的提问来源于stack exchange,提问作者Karolis

