Ionic serve failing in example projects after fresh install


#1

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.


Ionic 3 error after update
#2

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


#3

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.


#4

It seems that the package.json is broken in the template. See 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.


Ionic 2 Module Build Failed
#5

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


#6

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.


#7

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


[ionic-app-scripts 0.0.45] Browser not opening automatically
#8

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

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 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:

Thnx
Lis


[ionic-app-scripts 0.0.45] Browser not opening automatically
#9

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 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.


#10

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


#11

@danbucholtz, I’ve created a new topic to follow the browser-not-opening-automatically thing, here


#12

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)