Ionic 2 Module Build Failed

I created an ionic2 app and immediately run ionic serve. Everything look good in my command line but it shows white screen in browser. I found error message in the console the reads:

webpack:///./src/pages/tabs/tabs.ts?:1 Uncaught Error: Module build failed: TypeError: Cannot read    property 'content' of undefined
at Object.typescriptSourcemapLoaderMemory (C:\Dev\MobileApps\myApp\node_modules\@ionic\app- scripts\dist\webpack\typescript-sourcemap-loader-memory.js:18:34)
at Object.typescriptSourcemapLoaderMemory (C:\Dev\MobileApps\myApp\node_modules\@ionic\app-scripts\dist\webpack\typescript-sourcemap-loader-memory.js:18:34)
at eval (webpack:///./src/pages/tabs/tabs.ts?:1:7)
at Object.<anonymous> (http://localhost:8100/build/main.js:1463:1)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at eval (webpack:///./src/app/app.component.ts?:4:75)
at Object.<anonymous> (http://localhost:8100/build/main.js:3184:1)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at eval (webpack:///./src/app/app.module.ts?:3:73)
at Object.<anonymous> (http://localhost:8100/build/main.js:3170:1)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at eval (webpack:///./src/app/main.dev.ts?:2:70)

Has anybody come across this issue? How can it be resolved?

I had the same error but for the blank and tutorial start projects.

Try to read this issue and this.

I read it too, but it didn’t help me.

Then i found that there is no built files in my output www folder.
So, i ran:

npm run ionic:build
ionic serve

And it solved the problem above.

ionic:build - it’s npm script in package.json file.

If you will still have an error, try update ionic-app-script

npm install @ionic/app-scripts@latest --save-dev

And if will not work try reinstall ionic.

npm uninstall ionic
npm install ionic

Instructions before was good, but if i run

npm run ionic:watch

and change some .ts file, project rebuild (build, transpile, webpack) and i’v got the same issue as author.
I have to run again

npm run ionic:build

It took about 50 sec on every run and it’s very uncomfortable for delepoment process.
image

I think it’s bug, very annoying bug.

@danbucholtz can you help us?

>ionic info

Your system information:

 ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.2
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
Ionic App Scripts Version: 0.0.44
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 8.1
Node Version: v6.2.1
Xcode version: Not installed

If i build with --dev environment i have the issue, thus i can’t use proxy for CORS.

Had the same error after upgrading to ionic-app-scripts 0.0.44. It seems like it tries to access one of my .ts file in title case, (like …/User/User.ts instead of …/user/user.ts) and after that it gets undefined.

Downgraded again to 0.0.30. Now it’s working.

Ok, finally i won :slight_smile:

npm uninstall -g ionic
npm cache clean
npm install -g ionic

Remove node_modules folder from my project.
Remove .tmp folder from my project.

npm install
npm run ionic:build-dev

ionic:build-dev it’s script from package.json

  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:build-dev": "ionic-app-scripts build --dev",
    "ionic:watch": "ionic-app-scripts watch"
  },

ionic serve

Profit :slight_smile:

Finally i lose (

ionic:watch get the same error as author described.
And after watch ionic:build-dev not build properly.

Started project with v1.3 …

Please update to the latest version of app-scripts and the ionic cli

npm install -g ionic@latest
npm install @ionic/app-scripts@latest

The package.json script section should look like this.

That would be a good first step in tracking this down. Once you have that in place, can you provide more info on what’s going on so we can try to resolve it. Can you run ionic info in your project directory, etc.

Thanks,
Dan

Finally i won! Workaround: https://github.com/driftyco/ionic-app-scripts/issues/439#issuecomment-265358586