0

I have Visual Studio Code on a desktop running Windows 11, and whenever I try to install any extension, or even just try to list extensions, I get the following error:

[error] [Window] Expected ',' or ']' after array element in JSON at position 5609 (line
1 column 5610): SyntaxError: Expected ',' or ']' after array element in JSON at position
5609 (line 1 column 5610)
    at JSON.parse (<anonymous>)
    at Object.factory (file:///c:/Program%20Files/Microsoft%20VS%20Code/resources/app/
out/vs/code/electron-utility/sharedProcess/sharedProcessMain.js:74:29808)

When I look at the file referenced above, the location (line 1 column 5610) appears to be the middle of a word. Even if I could make any sense of the referenced location, I wouldn't have any idea what I would need to do to correct the error properly. I get basically the same error when I try to install an extension from the command line, or even just running the command code --list-extensions.

I tried installing extensions using the 'User install' version of Visual Studio Code, the 'System install' version, and an older 'System install' version, and I get the same results every time. I also tried to install extensions from the command line, and the results were also the same. However, I have the equivalent version installed on a Linux system (the same version number), and I can install Extensions just fine.

Even after numerous searches (on the Stack Exchange sites and elsewhere), I have been completely unable to find any relevant info that can explain or resolve this problem.

2
  • where are you seeing this error originally? in the devtools? in the output panel? (if so, which channel?) the parsing error is not necessarily an issue parsing text in the linked file, which I assume is the file where the parse is being requested. it's not clear to me from just this message what the text failing to parse is, or where it is. does the message look exactly the same when trying to use those commandline commands you listed? do any other commandline commands work? like code --version? Commented Oct 31 at 1:23
  • It appears as soon as I open the editor, and the error is shown again when I open the extensions side pane. If I try to run anything from the command line, I only get the error message. The problem is that I can't find anything in the file referenced in the error message to explain this error (the location "column 5610" is in the middle of a word). That's really the crux of the issue -- which file is the actually source of the problem. I eventually did find the cause in a completely different file (see my answer below). Commented Oct 31 at 3:06

2 Answers 2

2

The main problem was that the error message pointed to a file that (1) wasn't a 'json' file at all, and (2) didn't have anything in that location (column 5610) that related to the parsing error described. Without any hint as to which file actually had the error, this turned into a hunt for the offending 'json' file.

Since the error was echoed to the 'output' window every time I initially started the VS Code editor, or opened the 'Extensions' side pane (i.e., when VS Code displayed the list of all extensions, either installed or available), I thought it might be in some kind of database file where the entire list of extensions is kept, namely:

C:\Users\<UserName>\.vscode\extensions\extensions.json

When I examined it, I did in-fact find the error described, along with an extra "]" character at the end. Adding a comma at the specified location and deleting the superfluous bracket corrected the problem.

Sign up to request clarification or add additional context in comments.

3 Comments

interesting. I'm curious how the file ended up in a malformed state. my understanding is it's managed by VS Code.
See my answer here: stackoverflow.com/a/76535192. There are a few related issues on GitHub. E.g., github.com/microsoft/vscode/issues/190813. Something must have interrupted a "non-atomic" write to extensions.json. Good find on thinking it was that file. It seems safe to delete extesnions.json if it is corrupted, it will be recreated by vscode.
The description for that post was just different enough that I didn't find it before, but it does appear to be related. Thanks for the reference.
0

One of the solutions would be to rename the workspaceStorage folder. You can locate it as follows: %APPDATA%\Code\User\workspaceStorage. Close Visual Studio Code, make the change, and then start it again. This folder will be recreated automatically and should clear the temporary data of the extensions. If everything works fine, you can delete it.

Alternatively, you can perform a clean installation without configurations or extensions, depending on your setup. Normally, existing data is not deleted. You can rename the Code folder to Code_backup to preserve your configuration. If everything works fine, you can delete it later, or if needed, you can find it at %APPDATA%\Code.

3 Comments

Renaming the workspaceStorage folder has no effect whatsoever. I also tried completely deleting the Code folder after uninstalling VS Code, then reinstalling, and that had no effect either.
"Well, since it indicates there's a syntax error, try checking the JSON file (%APPDATA%\Code\User\settings.json) and locate "line 1, column 5610 (position 5609)". Something might be missing, such as a bracket or braces that need to be closed or opened, a quote ("), or a comma (,). The other option is to rename that JSON file, so Visual Code creates it when starting up."
The settings.json file is only 51 characters long (on multiple lines), so the error doesn't make sense for that file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.