I think it is bug in index.js. I just replicate what you did but differently, and got to the same result:
I run index.js in a .hgt file, then replaced the "],[" by new lines and removed any extra "[" or "]" doing
cat heights.json | sed 's/\],\[/\n/g' | tr -d ']' | tr -d '[' > heights.csv
Then loading the csv in matlab in fact produced an error of inconsistency in the number of columns per row.
By counting the number of commas per line using:
sed 's/[^,]//g' heights+cr.txt | awk '{ print length }'
It indeed show that the first row has 1202 columns, the last 1200 columns and all the rest 1201 columns.
However, after loading the same .htg file directly in Matlab, it produce a nice 1201x1201 matrix.
You can load it directly in Matlab with the following code:
fileID=fopen('S40W067.hgt','r');% Replace by your HTG file
data = fread(fileID,[1201,1300],'uint16',0,'b');
fclose(fileID);
If you rather python, this question show some code examples.
By looking at the data from index.js and from Matlab, it seem that if you move the extra element at the end of row one, to be the first of row two, and then the last of two to be the first of the third row and so on, you will end up with the correct 1201x1201 data matrix.