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

Unexpected token } in JSON #26131

Closed
maccman opened this issue Jun 15, 2021 · 8 comments
Closed

Unexpected token } in JSON #26131

maccman opened this issue Jun 15, 2021 · 8 comments
Labels
bug Issue was opened via the bug report template.

Comments

@maccman
Copy link

maccman commented Jun 15, 2021

What version of Next.js are you using?

11

What version of Node.js are you using?

v14.16.1

What browser are you using?

Chrome

What operating system are you using?

macOs

How are you deploying your application?

Vercel

Describe the Bug

I've just upgraded to Next 11 from 10.2.3. When I try and run yarn dev I get:

alex@m1 reflect % yarn dev
yarn run v1.22.10
$ next
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/alex/repos/reflect/.env.local
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
> [PWA] PWA support is disabled
error - ./node_modules/next/dist/client/dev/amp-dev.js
SyntaxError: Unexpected token } in JSON at position 460
    at JSON.parse (<anonymous>)

Expected Behavior

Server should run.

To Reproduce

I'm assuming it's a babel issue - here's my babelrc file:

{
  "presets": [
    "@babel/preset-typescript",
    "@babel/preset-react",
    "@babel/preset-env",
    [
      "next/babel",
      {
        "preset-env": {
          "useBuiltIns": false,
          "targets": "Chrome >= 60, Safari >= 10.1, iOS >= 10.3, Firefox >= 54, Edge >= 15"
        }
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "dynamic-import-node",
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ],
}
@maccman maccman added the bug Issue was opened via the bug report template. label Jun 15, 2021
@davidye
Copy link

davidye commented Jun 15, 2021

Seems babelrc must be a valid JSON now - you have a trailing comma at the end.

@jwilsson
Copy link
Contributor

Babel uses JSON5 to parse .babelrc-files, I think it would make sense to do the same here. I'd be happy to submit a PR for it.

@maccman
Copy link
Author

maccman commented Jun 15, 2021

Fix that, now getting this error:

ReferenceError: regeneratorRuntime is not defined
    at eval (webpack-internal:///./app/models/book/book-store.ts:141:59)
    at _class2.books (webpack-internal:///./app/models/book/book-store.ts:202:6)
    at eval (webpack-internal:///./app/models/book/book-store.ts:206:2)
    at Object../app/models/book/book-store.ts (/Users/alex/repos/reflect/.next/server/pages/_app.js:2714:1)
    at __webpack_require__ (/Users/alex/repos/reflect/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./app/models/index.ts:12:74)
    at Object../app/models/index.ts (/Users/alex/repos/reflect/.next/server/pages/_app.js:2813:1)
    at __webpack_require__ (/Users/alex/repos/reflect/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./services/api/meetings.ts:6:68)
    at Object../services/api/meetings.ts (/Users/alex/repos/reflect/.next/server/pages/_app.js:4732:1)

@maccman
Copy link
Author

maccman commented Jun 15, 2021

I can't reproduce this on a bare instance of nextjs though, so I'm going to close this until I have more information.

@maccman maccman closed this as completed Jun 15, 2021
@maccman
Copy link
Author

maccman commented Jun 15, 2021

If anyone come across the same issue, I solved it by deleting my .next cache. Perhaps should be part of the upgrade guide if it isn't.

@GorvGoyl
Copy link
Contributor

I had a commented line in .babelrc file, removing that worked for me.

@timneutkens
Copy link
Member

This has been solved in next@canary.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

6 participants