Follow Me:

Sunday 2 July 2017

ReactJS Webpack Module build failed: Error: Cannot find module

Running the npm start in reactjs by using nodejs, its throwing error like "Module build failed: Error: Cannot find module".


Module build failed: Error: Cannot find module 'locate-path'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (F:\php\htdocs\reactjs\node_modules\pkg-dir\node_modul
es\find-up\index.js:3:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-serve
r ./main.js
webpack: Failed to compile.

Solution:

Actually when running the script that time corresponding module is not available. For this excute below commands, that is issue will be resolved.

1. To find the webpack errors 
Run your webpack with display-error-details option to enable more debugging on the errors.

webpack --progress --color --watch --display-error-details


2. Run below Commands in your command promt

npm list -g

npm install --global  [Your Missing Module Name]

npm install --global locate-path

npm install wisp --save
npm install --global --verbose promised-io

3. Set your Environment variable

For Windows:

set NODE_PATH=C:\Users\codingslover\AppData\Roaming\npm\node_modules

4. Check Module Folder

Sometimes our installed available in our user appdata folders also. So that goto
C:\Users\codingslover\AppData\Roaming\npm\node_modules
folder, find the missing modules and copy the module and place into your execution folder.

Example : 

I am executing my reactjs npm module in
F:php/htdocs/reacttest/
, inside module folder need to check module availability.





Categories: , ,

3 comments: