# Ionic serve failing in example projects after fresh install

**URL:** <https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099>\
**Category:** ionic-v3\
**Created:** [November 14, 2016, 11:48am UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099 "2016-11-14T11:48:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![limack](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@limack](https://forum.ionicframework.com/u/limack)\
**Post date:** [November 14, 2016, 11:48am UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/1 "2016-11-14T11:48:23Z")

</div>

I’m currently trying to set up a basic ionic 2 project. I’ve had everything working fine in v1, but after moving to v2 and fixing some VCBuild-related issues by installing a Windows SDK, `ionic serve` fails after creating a new project via `ionic start MyApp blank --v2`.

I get normal output from the script:

```
[20:53:13] ionic-app-scripts 0.0.43
[20:53:13] watch started ...
[20:53:13] build dev started ...
[20:53:13] clean started ...
[20:53:13] clean finished in 16 ms
[20:53:13] copy started ...
[20:53:13] transpile started ...
[20:53:18] transpile finished in 5.17 s
[20:53:18] webpack started ...
[20:53:18] copy finished in 5.40 s
[20:53:18] webpack finished in 281 ms
[20:53:18] sass started ...
[20:53:20] sass finished in 1.33 s
[20:53:20] build dev finished in 6.79 s
[20:53:20] watch ready in 6.95 s
[20:53:20] dev server running: http://localhost:8100/

```

But the page delivered in-browser is blank with the following Javascript error in the console:

```
Uncaught Error: Module build failed: TypeError: Cannot read property 'content' of undefined
    at Object.typescriptSourcemapLoaderMemory (C:\Users\Me\Documents\ionic\MyApp\node_modules\@ionic\app-scripts\dist\webpack\typescript-sourcemap-loader-memory.js:18:34)
    at Object.typescriptSourcemapLoaderMemory (C:\Users\Me\Documents\ionic\MyApp\node_modules\@ionic\app-scripts\dist\webpack\typescript-sourcemap-loader-memory.js:18:34)
    at eval (webpack:///C:/Users/Me/Documents/ionic/MyApp/src/app/main.dev.ts?:1:7)
    at Object.<anonymous> (http://localhost:8100/build/main.js:71:1)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at http://localhost:8100/build/main.js:64:18
    at http://localhost:8100/build/main.js:67:10

```

Upon further inspection, the www/build/main.js file that should be built from the typescript source has the source of this error at the end:

```
/ ****** / ([
/* 0 */
/***/ function(module, exports) {

eval("throw new Error(\"Module build failed: TypeError: Cannot read property 'content' of undefined\\n at Object.typescriptSourcemapLoaderMemory (C:\\\\Users\\\\Mack\\\\Documents\\\\ionic\\\\chatroom\\\\node_modules\\\\@ionic\\\\app-scripts\\\\dist\\\\webpack\\\\typescript-sourcemap-loader-memory.js:18:34)\");\n\n//////////////////\n// WEBPACK FOOTER\n// C:/Users/Mack/Documents/ionic/chatroom/src/app/main.dev.ts\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///C:/Users/Mack/Documents/ionic/chatroom/src/app/main.dev.ts?");

/***/ }
/ ****** / ]);

```

So it appears that the problem lies in the typescript build process - but none of the scripts complain. Cleaning and/or manually deleting the www/build directory has no effect, the file is rebuilt identically.

I searched but haven’t found any similar error related to ionic/cordova. Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![mirkonasato](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirkonasato/32/131398_2.png) [@mirkonasato](https://forum.ionicframework.com/u/mirkonasato)\
**Post date:** [November 14, 2016, 12:36pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/2 "2016-11-14T12:36:54Z")

</div>

What versions of the various tools do you have installed? Type `ionic info` and paste the output here.

---

<div class="post-metadata">

**Author:** ![limack](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@limack](https://forum.ionicframework.com/u/limack)\
**Post date:** [November 14, 2016, 12:50pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/3 "2016-11-14T12:50:59Z")

</div>

Oops, forgot to add that the first time:

```
 ordova CLI: 6.4.0
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7
Node Version: v6.9.1
Xcode version: Not installed

```

npm is version 3.10.8, if that is relevant.

---

<div class="post-metadata">

**Author:** ![jrierab](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jrierab](https://forum.ionicframework.com/u/jrierab)\
**Post date:** [November 15, 2016, 7:53am UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/4 "2016-11-15T07:53:43Z")

</div>

It seems that the package.json is broken in the template. See [https://github.com/driftyco/ionic-cli/issues/1660#issuecomment-260122096](https://github.com/driftyco/ionic-cli/issues/1660#issuecomment-260122096).

To fix, remove “ionic:build” and “ionic:serve” in the “scripts” part and leave it like that:

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

```

It’s commented [https://github.com/driftyco/ionic-app-scripts#npm-scripts](https://github.com/driftyco/ionic-app-scripts#npm-scripts).

---

<div class="post-metadata">

**Author:** ![danbucholtz](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danbucholtz/32/99512_2.png) [@danbucholtz](https://forum.ionicframework.com/u/danbucholtz)\
**Post date:** [November 21, 2016, 4:16pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/5 "2016-11-21T16:16:31Z")

</div>

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

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

```

The package.json script section should look like [this](https://github.com/driftyco/ionic2-app-base/blob/master/package.json#L6-L9).

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

---

<div class="post-metadata">

**Author:** ![jrierab](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jrierab](https://forum.ionicframework.com/u/jrierab)\
**Post date:** [November 21, 2016, 5:13pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/6 "2016-11-21T17:13:55Z")

</div>

It’s working now. It was 0.043 which had the problems…

My only little issue is that it does not automatically start the page in the browser (the first time). But it requires only a click, so no problem.

When code changes, the reloading seems to be much more smooth, and fast.

And even the [Object Object] output is solved !

So, good work and many thanks @danbucholtz.

---

<div class="post-metadata">

**Author:** ![danbucholtz](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/danbucholtz/32/99512_2.png) [@danbucholtz](https://forum.ionicframework.com/u/danbucholtz)\
**Post date:** [November 21, 2016, 5:24pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/7 "2016-11-21T17:24:58Z")

</div>

What OS are you on? The browser-not-opening-automatically thing is a bug that we need to fix. I haven’t been able to recreate it.

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![lisaiceland](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lisaiceland/32/104799_2.png) [@lisaiceland](https://forum.ionicframework.com/u/lisaiceland)\
**Post date:** [November 21, 2016, 5:55pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/8 "2016-11-21T17:55:15Z")

</div>

Dan hi.  
I’m having an issue with Ionic 2 running, period.  
Can u plz help me with this. Can;'t run ionic at all.  
I’ve checked & done chowns to make sure as well:

sudo uninstall -g ionic

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

ionic info gets:

ionic info  
Unable to parse Ionic Config file. Please make sure it is valid JSON (.ionic/ionic.config)  
Caught exception:  
SyntaxError: Unexpected end of JSON input  
at Object.parse (native)  
at Object.load (/usr/local/lib/node\_modules/ionic/node\_modules/ionic-app-lib/lib/config.js:14:26)  
at Object. (/usr/local/lib/node\_modules/ionic/lib/utils/stats.js:31:31)  
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)  
at Module.require (module.js:497:17)  
at require (internal/module.js:20:19)

Mind letting us know? [https://github.com/driftyco/ionic-cli/issues](https://github.com/driftyco/ionic-cli/issues)

**OK NEVER MIND, GOT THE SOLUTION:**  
\*\* #UPDATE 11/21/2016: Houston, we have a go woohoo!\*\*  
Ughhhh…kool finally can go back to work with Ionic 2!  
OK: Found the fix here: [https://forum.ionicframework.com/t/ionic-command-not-work/19452/5You’ll](https://forum.ionicframework.com/t/ionic-command-not-work/19452/5You'll) want to edit the file, .eg:  
sudo nano /usr/local/lib/node\_modules/ionic-app-lib/lib/config.js

or $ cd /usr/local/lib/node\_modules/ionic-app-lib/lib/  
$ atom . or $code . or whatever. Open the config.js file in the dir

then…change line 7 as it is if you install ionic@latest as of 11/21/2016:  
CONFIG\_FILE: ‘.ionic/ionic.config’,  
To have a slash after the dot:

CONFIG\_FILE: ‘./ionic/ionic.config’,

Then save the file, and try running an ionic command:  
ionic info or whatever Ionic CLI command you need to run!  
Done.

**ALSO UPDATED THE ISSUE:**

> <https://github.com/ionic-team/ionic-cli/issues/1696>

Thnx  
Lis

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [November 22, 2016, 3:43am UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/9 "2016-11-22T03:43:51Z")

</div>

Not that there’s particularly any reason for you to care about my opinion, but I think that in general for people reading this thread, there are two things you should attempt to avoid if at all possible:

- running npm as root (aka all the ‘sudo’ you see in comments)  
[nvm](https://github.com/creationix/nvm) does a great job of managing node versions without requiring privilege escalation.

- modifying things underneath `node_modules` in your project directories. npm hates it when you do this and will overwrite your modifications often, without notice, and when it is most likely to ruin your life.

---

<div class="post-metadata">

**Author:** ![lisaiceland](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lisaiceland/32/104799_2.png) [@lisaiceland](https://forum.ionicframework.com/u/lisaiceland)\
**Post date:** [November 22, 2016, 4:57am UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/10 "2016-11-22T04:57:35Z")

</div>

Great point Robert and YES your opinion is greatly valued by us! 😉 Bless. Lis

---

<div class="post-metadata">

**Author:** ![jrierab](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@jrierab](https://forum.ionicframework.com/u/jrierab)\
**Post date:** [November 22, 2016, 8:37am UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/11 "2016-11-22T08:37:31Z")

</div>

@danbucholtz, I’ve created a new topic to follow the browser-not-opening-automatically thing, [here](https://forum.ionicframework.com/t/ionic-app-scripts-0-0-45-browser-not-opening-automatically/70979)

---

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [January 5, 2017, 7:06pm UTC](https://forum.ionicframework.com/t/ionic-serve-failing-in-example-projects-after-fresh-install/70099/12 "2017-01-05T19:06:06Z")

</div>

Did you manage to fix this?

> ```
> Error: Module build failed: TypeError: Cannot read property 'content' of undefined
> at Object.typescriptSourcemapLoaderMemory (E:\Development\IDE\ionic-apps\firebase-chat-master\node_modules\@ionic\app-scripts\dist\webpack\typescript-sourcemap-loader-memory.js:21:34)
> 
> ```
