Next.js: SyntaxError: Unexpected token ' in JSON at position 0

Created on 12 Mar 2018  路  15Comments  路  Source: vercel/next.js

Most helpful comment

Hmm, could be something to do with quotes on Windows 馃 I'm not sure how exactly to fix this as I don't have a machine on which I could reproduce this.

Can you try playing with nested quotes in package.json? E.g. smth like:

"ts": "ts-node --compilerOptions \"{\\\"module\\\":\\\"commonjs\\\"}\"" 

etc.

All 15 comments

did you resolve this?

not yet锛孖 just give up use TS - - !

@kachkaev could you check this 馃檹

@minooo what command did you run when the error occurred? Could you please share a bit more of your output?

@kachkaev when I type yarn dev from examples/custom-server-typescript, I get this error.

image

Hmm, could be something to do with quotes on Windows 馃 I'm not sure how exactly to fix this as I don't have a machine on which I could reproduce this.

Can you try playing with nested quotes in package.json? E.g. smth like:

"ts": "ts-node --compilerOptions \"{\\\"module\\\":\\\"commonjs\\\"}\"" 

etc.

@kachkaev Sorry for late response. It works after replacing the command. Thank you. Suck to be Windows user 馃槀馃槀馃槀

Thank you, evereone!

SyntaxError: Unexpected token p in JSON at position 2
at JSON.parse ()
at Object.Utils.JSON.parse (/Users/Admin/Desktop/bitshare/node_modules/jayson/lib/utils.js:274:26)
at IncomingMessage. (/Users/Admin/Desktop/bitshare/node_modules/jayson/lib/client/http.js:75:22)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1081:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

this is the errror which comes from bitshare-rpc, how can i resolve this??

did anyone resolve this?

did anyone resolve this?

The solution from @kachkaev worked for me.

So escaping the quotes works. However does this mean it will break in team environments where everyone else is using OSX machines?

SyntaxError: Unexpected token / in JSON at position 0
at JSON.parse ()
at Object.Module._extensions..json (internal/modules/cjs/loader.js:795:27)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (C:UsersbestDesktopexpress_exceedserver.js:14:15)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
[nodemon] app crashed - waiting for file changes before starting...

How can I solve it ??

Hi @kachkaev I didn't use any command line in package json. Locally my program runs when it deployed i getting the Error like:
SyntaxError: Unexpected token - in JSON at position 0
at JSON.parse ()
at createStrictSyntaxError (/srv/api/node_modules/body-parser/lib/types/json.js:158:10)
at parse (/srv/api/node_modules/body-parser/lib/types/json.js:83:15)
at /srv/api/node_modules/body-parser/lib/read.js:121:18
at invokeCallback (/srv/api/node_modules/raw-body/index.js:224:16)
at done (/srv/api/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/srv/api/node_modules/raw-body/index.js:273:7)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)

if using fetch, check your headers content-Type, you might want to remove it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flybayer picture flybayer  路  3Comments

lixiaoyan picture lixiaoyan  路  3Comments

knipferrc picture knipferrc  路  3Comments

rauchg picture rauchg  路  3Comments

havefive picture havefive  路  3Comments