ReduxSimpleStarter
ReduxSimpleStarter copied to clipboard
Error: Cannot find module "./src/index.js"
Running the project with WebStorm produces this error: ERROR in ./src/index.js Module build failed: SyntaxError: D:/Modern React with Redux Workspace/ReduxSimpleStarter/src/index.js: Unexpected token (6:4)
4 | // Create a new component. It should produce html.
5 | const App = () => (
> 6 | return <div>Hi!</div>;
| ^
7 | )
Please assist.
Turns out this is what one puts in the class body these days.
const App = () => ( <div>Hi!</div> )
This helped me find that out: https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-0&targets=&browsers=&builtIns=false&code=const%20App%20%3D%20()%20%3D%3E%20(%0A%20%20%3Cdiv%3EHi!%3C%2Fdiv%3E%0A)
const App =() => {return <div> Hi! </div>} curly brackets
or
const App = () => ( <div>Hi!</div> )
Here's the full console error. New syntax for the const doesn't solve the problem
Uncaught Error: Cannot find module "./src/index.js"
at webpackMissingModule (bundle.js:47)
at Object.
I've solved the issue. If you're following his Udemy video; at some point he asks you to delete the 'src' folder, recreate it, then create a new file inside called 'index.js'. INSTEAD OF deleting the entire 'src' folder, delete the other subfolders in 'src' and leave the 'index.js' inside 'src' (the one that's in the root of 'src'). You can delete all the lines of code in 'index.js' and start from there for his videos.
I believe this has something to do with the IDE or server automatically adding dependencies to the module. Personally I ran into the same problem using bash and the IDE 'visual studio code' on mac.
Had the same error, but actually whats happening is the ; that you had at line 6. Without that, it's error free. Cheers!
still having this issue, tried to deploy the weather app but i get the same error which is :
bundle.js:1 Uncaught Error: Cannot find module "./src/index.js" at bundle.js:1 at Object.<anonymous> (bundle.js:1) at n (bundle.js:1) at bundle.js:1 at bundle.js:1
my code located at : https://github.com/yonarbel/reactWeatherApp
I had similar problem, in my case the problem was I had to start the webpack . Use this command to start the webpack : webpack--w
I tried writing the code differently and that worked, but after installing the latest version of webpack the code as it is written in the tutorial works.
Worked for me once I removed the curly braces and kept the return statement on one line.
const App = () => {
return <div><SearchBar /></div>;
}
I had the same problem, then change the return curly brackets to normal brackets and all seemed to be fine:
const App = ()=> { return ( <div> <SearchBar /> </div> ); };
I am using Atom in MacOS system and I had the same problem. I first installed the webpack just in case, the pack is not there with the pack, using:
npm install -S webpack
Then, I updated the webpack:
webpack--w
Finally, I restarted the server: npm start, which finally solved the problem.
try using this {} brackets instead of using ().
I got the same error. Just in case it helps anyone out, the cause was my missing a closing ) and a ; in this code:
return (
<VideoListItem
onVideoSelect={props.onVideoSelect}
key={video.etag}
video={video} />
);
});