petehunt / webpack-howto

10.12k stars 697 forks source link

"Module not found: Error: Cannot resolve module" for react-router and react #30

Open frg opened 9 years ago

frg commented 9 years ago

Hi,

Hopefully this is not a total noob question, but;

When I run 'webpack' I keep getting a "Module not found: Error: Cannot resolve module" for 'react-router' and 'react'.

Just for clarity I'm running 'npm install' in the example directory and then running 'webpack' in the same directory.

Would appreciate it if someone could help me out :)

Thanks in advance, Jean

coryhouse commented 9 years ago

I'm getting the same. Running on OSX. Here's my version info:

npm version { 'webpack-howto-example': '1.0.0', npm: '2.9.1', http_parser: '2.3', modules: '14', node: '0.12.3', openssl: '1.0.1m', uv: '1.5.0', v8: '3.28.71.19', zlib: '1.2.8' }

And here's the output of running npm start: npm start

webpack-howto-example@1.0.0 start /Users/coryhouse/Desktop/webpack-howto/example webpack-dev-server

http://localhost:8080/webpack-dev-server/ webpack result is served from / content is served from /Users/coryhouse/Desktop/webpack-howto/example Hash: 095a517d0e7e20ad100b Version: webpack 1.10.1 Time: 237ms Asset Size Chunks Chunk Names bundle.js 11.4 kB 0 [emitted] main chunk {0} bundle.js (main) 8.74 kB [rendered] [0] ./modules/main.js 547 bytes {0} [built] [2 errors] [1] ./modules/App.js 554 bytes {0} [built] [2 errors] [2] ./modules/App.css 1.15 kB {0} [built] [3] ./~/css-loader!./modules/App.css 200 bytes {0} [built] [4] ./~/css-loader/cssToString.js 352 bytes {0} [built] [5] ./~/style-loader/addStyles.js 5.51 kB {0} [built] [6] ./modules/Home.js 214 bytes {0} [built] [1 error] [7] ./modules/About.js 218 bytes {0} [built] [1 error]

ERROR in ./modules/main.js Module not found: Error: Cannot resolve module 'react' in /Users/coryhouse/Desktop/webpack-howto/example/modules @ ./modules/main.js 6:12-28

ERROR in ./modules/main.js Module not found: Error: Cannot resolve module 'react-router' in /Users/coryhouse/Desktop/webpack-howto/example/modules @ ./modules/main.js 7:13-36

ERROR in ./modules/Home.js Module not found: Error: Cannot resolve module 'react' in /Users/coryhouse/Desktop/webpack-howto/example/modules @ ./modules/Home.js 3:12-28

ERROR in ./modules/App.js Module not found: Error: Cannot resolve module 'react' in /Users/coryhouse/Desktop/webpack-howto/example/modules @ ./modules/App.js 3:12-28

ERROR in ./modules/App.js Module not found: Error: Cannot resolve module 'react-router' in /Users/coryhouse/Desktop/webpack-howto/example/modules @ ./modules/App.js 4:12-35

ERROR in ./modules/About.js Module not found: Error: Cannot resolve module 'react' in /Users/coryhouse/Desktop/webpack-howto/example/modules @ ./modules/About.js 3:12-28 webpack: bundle is now VALID.

tcoopman commented 9 years ago

I see that the package.json points to the git master for both react and react-router. Have you tried with the latest stable versions?

coryhouse commented 9 years ago

@tcoopman Good call! I uninstalled react, router-router, and react-tools and then reinstalled them to remove the hard reference to master. It now runs without error.

So looks like the simple fix is to remove the hard reference to master in package.json.

tcoopman commented 9 years ago

create a PR #32

gaurav-technologydata commented 6 years ago

./src/Component/Form.js Module not found: Can't resolve '../axios' in 'F:\React\react-complete-guide\src\Component'

i am getting this issue........i have deleted that json-lock file then fire npm install command then npm start still i m getting same issue

gaurav-technologydata commented 6 years ago

this question is already asked by no. of people but still there is no answer

KaviiChathuranga commented 6 years ago

please tell how to fix modules missing error