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

Cannot upgrade to next@11 - Unexpected token / in JSON at position 0 #26132

Closed
MaximeBernard opened this issue Jun 15, 2021 · 6 comments
Closed
Labels
bug Issue was opened via the bug report template.

Comments

@MaximeBernard
Copy link

What version of Next.js are you using?

11.0.0

What version of Node.js are you using?

16.3.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Docker

Describe the Bug

After installing next@11 & eslint-config-next, I can't build nor dev anymore.

$ next build
...
info  - Creating an optimized production build
Failed to compile.

./node_modules/next/dist/client/next.js
SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)


> Build error occurred
Error: > Build failed because of webpack errors
    at /Users/XXX/YYY/packages/website/node_modules/next/dist/build/index.js:15:924
    at async Span.traceAsyncFn (/Users/XXX/YYY/packages/website/node_modules/next/dist/telemetry/trace/trace.js:6:584)
error Command failed with exit code 1.
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
error - ./node_modules/next/dist/client/dev/amp-dev.js
SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
event - build page: /next/dist/pages/_error
wait  - compiling...
error - ./node_modules/next/dist/client/dev/amp-dev.js
SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
Error: Cannot find module '/Users/XXX/YYY/packages/website/.next/server/pages-manifest.json'

Expected Behavior

Should work without issues

To Reproduce

I can't share my project but I had TS, ESlint & Jest already setup and working in next@10.

Error is not very explicit, maybe you can guide me through some try...catch that would be more helpful?

@MaximeBernard MaximeBernard added the bug Issue was opened via the bug report template. label Jun 15, 2021
@MaximeBernard MaximeBernard changed the title Cannot upgrade to next@11 Cannot upgrade to next@11 - Unexpected token / in JSON at position 0 Jun 15, 2021
@jacobdubail
Copy link

jacobdubail commented Jun 15, 2021

I was running into this as well. Here's how I just fixed it.

I have a few imports that are arrays of data:
export const colors = [ { id: 'all', title: 'All colours', icon: null, }, ... ]

The file extension was .ts. That worked fine in Next 10. I was finally able to get error output that pointed to this as an issue. Renaming to .tsx didn't work. Only .js will work and I don't know why.

@MaximeBernard
Copy link
Author

Thanks to #26203 I found out that downgrading

webpack5: false

solves the issue.

This seems like a regression (or at least a breaking change) to me as webpack5 configuration worked very fine in next10.

@jwilsson
Copy link
Contributor

This sounds like the same issue as #26163. A possible fix is out in v11.0.1-canary.2.

@timneutkens
Copy link
Member

Yeah duplicate of #26163

@MaximeBernard
Copy link
Author

Tried with 11.0.1-canary.4, problem seems to be solved. Thank you 🙏

@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

5 participants