ReduxSimpleStarter icon indicating copy to clipboard operation
ReduxSimpleStarter copied to clipboard

Error: Cannot find module "./src/index.js"

Open ElAnonimo opened this issue 8 years ago • 13 comments

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.

ElAnonimo avatar Feb 09 '17 11:02 ElAnonimo

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)

ElAnonimo avatar Feb 09 '17 14:02 ElAnonimo

const App =() => {return <div> Hi! </div>} curly brackets

or

const App = () => ( <div>Hi!</div> )

fuyu0425 avatar Feb 09 '17 15:02 fuyu0425

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. (bundle.js:47) at webpack_require (bundle.js:20) at bundle.js:40 at bundle.js:43

coozin avatar Feb 17 '17 13:02 coozin

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.

coozin avatar Feb 17 '17 14:02 coozin

Had the same error, but actually whats happening is the ; that you had at line 6. Without that, it's error free. Cheers!

gilgrencho avatar May 19 '17 14:05 gilgrencho

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

yonarbel avatar May 19 '17 20:05 yonarbel

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

telalwar avatar Sep 29 '17 13:09 telalwar

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.

castlemaninc avatar Jan 03 '18 01:01 castlemaninc

Worked for me once I removed the curly braces and kept the return statement on one line.

const App = () => {
    return <div><SearchBar /></div>;
}

ChrisThorn10 avatar Feb 02 '18 01:02 ChrisThorn10

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

adair21 avatar Feb 27 '18 17:02 adair21

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.

JintaoHe avatar Jun 21 '18 09:06 JintaoHe

try using this {} brackets instead of using ().

vinay72 avatar Sep 27 '18 01:09 vinay72

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

obwansan avatar Oct 31 '18 17:10 obwansan