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