Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected non-whitespace character after JSON at position 2 #538

Closed
Seventysevendays opened this issue Sep 19, 2023 · 16 comments

Comments

@Seventysevendays
Copy link

image

@kaisalmen
Copy link
Collaborator

@Seventysevendays there is no context!🤷‍♂️

@Seventysevendays
Copy link
Author

@Seventysevendays there is no context!🤷‍♂️

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

@kaisalmen
Copy link
Collaborator

kaisalmen commented Sep 19, 2023

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?

@cdietrich
Copy link
Contributor

cdietrich commented Sep 19, 2023

i remember such a problem with a bad (old) polyfill of buffer that used __PROTO__ which does not work on current browser

@Seventysevendays
Copy link
Author

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

@cdietrich
Copy link
Contributor

can you do a npm why buffer?

@Seventysevendays
Copy link
Author

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

@Seventysevendays
Copy link
Author

Seventysevendays commented Sep 19, 2023

the normal
image
image

in my repo
image
image

@cdietrich
Copy link
Contributor

cdietrich commented Sep 19, 2023

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

@CGNonofr
Copy link
Collaborator

The library checks if the Buffer class exists to use it (useful in a node/electron context)

@cdietrich
Copy link
Contributor

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

@CGNonofr
Copy link
Collaborator

Maybe if you import Buffer from 'buffer' you get the new version, but the code just does : const hasBuffer = (typeof Buffer !== 'undefined');

@cdietrich
Copy link
Contributor

cdietrich commented Sep 19, 2023

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

@Seventysevendays
Copy link
Author

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

@kaisalmen
Copy link
Collaborator

Thanks everyone.

@kaisalmen
Copy link
Collaborator

@Seventysevendays FYI added a new sub-section to the troubleshooting guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants