Cannot find module 'webpack' (CLI v2.0.0-beta.15)

Hello everyone,

After creating a new project with ‘ionic start MyIonic2Project tutorial --v2’, ionic serve give the following error:

∆ Compiling and bundling with Webpack…
There was an error loading webpack.config.js:

Error: Cannot find module 'webpack’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/Users/seb/GoogleDrive/WebDev/Ionic2/Drumy/webpack.config.js:2:15)
at Module._compile (module.js:425:26)
at Object.Module._extensions…js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)

Cannot find module ‘webpack’ (CLI v2.0.0-beta.15)

Your system information:

Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 2.0.0-alpha.45
Ionic CLI Version: 2.0.0-beta.15
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: Not installed
ios-sim version: 5.0.4
OS: Mac OS X El Capitan
Node Version: v5.1.0
Xcode version: Xcode 7.2 Build version 7C68

Have any idea ?

1 Like

getting the same…do let me know when u get a solution for this

Same error trying to execute ‘ionic serve’ with the ‘cutePuppyPics’ projects…

By the way, is it normal that the app folder stand aside the www folder and not inside of it ?

yes that’s the changes in ionic 2 due to angular 2…won’t be able to dig deep into it until i can build the damn thing

The error is that it appears they assume you have webpack as a global executable.

The general solution is to execute

npm install -g webpack

I prefer to keep my dependencies in my local project however so I would run

npm install webpack --save-dev --save-exact

This will install the webpack dependencies locally and not use a wishy washy version number. So you are guaranteed to get the same version next time you have to install.