Ionic JSON parse exception


My PC recently crashed while halfway through building my Ionic 2 project, and now I can’t run any ionic commands. When I try to run any ionic command in any of my ionic projects I get the following command output:

 SyntaxError: Unexpected token   in JSON at position 0
    at Object.parse (native)
    at Object.load (C:\Users\iyash\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\lib\config.js:13:24)
    at Object.<anonymous> (C:\Users\iyash\AppData\Roaming\npm\node_modules\ionic\lib\utils\stats.js:31:31)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)

I’ve tried removing all the node_modules in my project and reinstalling them as well as uninstalling and reinstalling both cordova and ionic. I’ve also cleared the contents of my www folder. I’ve removed and re-added my platforms using cordova commands, since ionic doesn’t work.

I can’t run ionic info to get my version info.

Any suggestion on what else I can do to get ionic working again?


Maybe, after reinstalling everything, did you check if your package.json was correct regarding the updated libs?


Ionic 2 RC.2:

App-Script 0.0.42:

If no, try to update package.json, delete and reinstall node_modules

Bug just a suggestion


My dependencies and app-scripts are up to date. This is definitely a global ionic issue. I can’t run any ionic commands in any directory.

I’m thinking there’s some global ionic cli cache somewhere that I need to clear.


sorry to hear and sorry for not having any other ideas right now


I have now also gone so far as to uninstall node, delete npm and npm-cache directories, run ccleaner to clean temp files, reboot, reinstall node, reinstall ionic and cordova.


I’ve found the source of the problem! My C:/Users/{username}/.ionic/ionic.config file was corrupted when my pc crashed.

Weird that that file NEVER gets cleared when uninstalling ionic.

Can anyone please post me the contents of theirs so I can see what to put in there?

EDIT: Nevermind, the file was filled the proper JSON object.


So, the first error was definitely because the file was not valid JSON. Perhaps the crash caused that corruption :frowning:

Were you able to get passed this error? Double check the file and make sure it really is valid (no dangling commas, etc.)