SyntaxError: Unexpected non-whitespace character after JSON at position 2
Seventysevendays opened this issue · comments
@Seventysevendays there is no context!🤷♂️
@Seventysevendays there is no context!🤷♂️
You did:
npm i
npm run build
npm run dev
and went to to the example via http://localhost:8080/packages/examples/react.html and it doesn't work?
i remember such a problem with a bad (old) polyfill of buffer
that used __PROTO__
which does not work on current browser
You did:
npm i npm run build npm run devand went to to the example via http://localhost:8080/packages/examples/react.html and it doesn't work?
in monaco-languageclient repo, it goes well, the same code in my repo, went wrong, but it was good before, so I think maybe caused by the package version, i tried change related package version, still not work
can you do a npm why buffer
?
i remember such a problem with a bad (old) polyfill of
buffer
that used__PROTO__
which does not work on current browser
do you know how to fix it? the buff all changed to number string, its confused
we use a newer buffer dependency in resolutions in package.json
"resolutions": {
"buffer": "^6.0.3",
}
but this is a yarn concept
the question is why does old buffer end up in your codebase
The library checks if the Buffer class exists to use it (useful in a node/electron context)
yes but old versions use PROTO to overide array methods which does not work in modern browser anymore.
newer versions uses Object.setPrototypeOf to redirect e.g. toString methods
Maybe if you import Buffer from 'buffer'
you get the new version, but the code just does : const hasBuffer = (typeof Buffer !== 'undefined');
yes so you are lost if there is an old buffer polyfill lurking around.
in in my project we overwrote the buffer
dependency to get current version of the polyfill
we use a newer buffer dependency in resolutions in package.json
"resolutions": { "buffer": "^6.0.3", }
but this is a yarn concept
the question is why does old buffer end up in your codebase
it works in my project, thx a lot
Thanks everyone.
@Seventysevendays FYI added a new sub-section to the troubleshooting guide.