TypeFox / monaco-languageclient

Repo hosts npm packages for monaco-languageclient, vscode-ws-jsonrpc, monaco-editor-wrapper, @typefox/monaco-editor-react and monaco-languageclient-examples

Home Page:https://www.npmjs.com/package/monaco-languageclient

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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!🤷‍♂️

sorry, it's the react example, I just run start,
image
image

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 dev

and 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

the normal
image
image

in my repo
image
image

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.