I have a Windows 8 app that I coded a while ago. I've been making the occasional update over the past year or so. I haven't really touched it in about 2 months. Now, all of a sudden, I'm getting the error "0x800a1391 - JavaScript runtime error: 'WinJS' is undefined" when I attempt to debug the app. The error appears in my default.js file, line 5.
I have this app in source control and I tried comparing the default.js and default.htm file to what I have in source control (which I know works, because it's out in production): they are the same. I've tried running Visual Studio 2013 normally and as Administrator to no avail. I've double checked that I have base.js and ui.js properly defined in default.htm (per this question here). I've also checked my WinJS 1.0 reference is correct in my project and verified that the files are where they are supposed to be in the file system. Intellisense works fine with the WinJS object at design-time. During debug, when I look at the DOM, I notice that base.js and ui.js aren't loaded, but other scripts are. This is obviously why I get the error.
Something to note: for the first time that I can remember, when I attempted to debug for the first time in a couple of months (as noted above), I was presented with a dialog asking about Script Diagnostics. I clicked and accepted the dialog. I don't remember ever being asked that before and certainly not for this project. Could this perhaps have something to do with the error?
I'm at a complete loss to figure this out. I've googled this error with no help. I've checked around SO to no avail either. Any help would be most appreciated as I do need to push out a fix soon, and without the ability to debug, I can't test my fix.
Another note: I don't think this should be an issue, but before this started happening, I had to replace my HDD due to bad sector errors. Everything was properly recovered and I haven't seen any other issues. This was done about a month ago in between the last time debug worked and this issue.
Edit: One more thing of possible interest... Not only can I not debug this app, but other Windows 8 apps will no longer run either. Apps like Bing Weather, Pinball FX2 and any other WinJS based apps all fail to load and crash during the splash screen. Non-WinJS apps seem to work fine. So, now I think this might be a WinJS specific issue. Permissions maybe? I've checked what I can to no avail.
Well, it looks like I've solved my own issue. Here's what I did...
First, re-install WinJS manually: nope.
Then, re-install VS 2012: nope.
Re-install VS2013: nope.
So then, I tried putting ALL APPLICATION PACKAGES with Full Control on my profile folder and Program Files. This was bad, don't do it!
To fix, I tried installing Windows 8 on top of itself. Didn't work. A Refresh/Reset wouldn't work either as I tried those first.
After messing up permissions, I reset all permissions on those folders with icacls using pre-saved/backup ACL files I had (phew!).
I then (since it had been a while) ran Windows Update and got 38 updates. Rebooted a couple of times and then everything started working again. (When the permissions where screwed up, I could only run things As Administrator or they would not function.)
After all this, I started getting a new error when I tried to debug my app and some of the other WinJS based apps I have. In my app, the error related to the state and no longer that it couldn't find WinJS files. I just uninstalled them (including my app) and either re-installed (Store apps) or tried debugging again and everything worked.
Very messy stuff and I still don't know what initially caused all of this. Thanks Kraig for the help. But, looks like I'm back to normal now.