question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: error: Expected ';', got 'assert' when trying to deploy on Vercel

See original GitHub issue

Summary

When trying to deploy on vercel a NextJs project with contentlayer installed I get this error message on vercel build:

Click to expand
[21:20:00.600] Cloning github.com/zaniluca/zaniluca.com (Branch: blog-setup, Commit: fac6d7f)
[21:20:01.007] Cloning completed: 406.525ms
[21:20:01.837] Looking up build cache...
[21:20:02.294] Build Cache not found
[21:20:02.518] Running "vercel build"
[21:20:02.993] Vercel CLI 25.2.0 build (beta) — https://vercel.com/feedback
[21:20:03.270] Installing dependencies...
[21:20:03.610] yarn install v1.22.17
[21:20:03.682] [1/4] Resolving packages...
[21:20:03.882] [2/4] Fetching packages...
[21:20:19.529] [3/4] Linking dependencies...
[21:20:19.530] warning "contentlayer > @contentlayer/source-files > date-fns-tz@1.3.5" has unmet peer dependency "date-fns@>=2.0.0".
[21:20:19.532] warning "contentlayer > @contentlayer/utils > @opentelemetry/exporter-trace-otlp-grpc > @opentelemetry/core@1.0.1" has incorrect peer dependency "@opentelemetry/api@>=1.0.0 <1.1.0".
[21:20:19.532] warning "contentlayer > @contentlayer/utils > @opentelemetry/exporter-trace-otlp-grpc > @opentelemetry/resources@1.0.1" has incorrect peer dependency "@opentelemetry/api@>=1.0.0 <1.1.0".
[21:20:19.534] warning "contentlayer > @contentlayer/utils > @opentelemetry/exporter-trace-otlp-grpc > @opentelemetry/sdk-trace-base@1.0.1" has incorrect peer dependency "@opentelemetry/api@>=1.0.0 <1.1.0".
[21:20:19.551] warning Workspaces can only be enabled in private projects.
[21:20:19.552] warning Workspaces can only be enabled in private projects.
[21:20:19.555] warning Workspaces can only be enabled in private projects.
[21:20:33.527] [4/4] Building fresh packages...
[21:20:36.513] Done in 32.91s.
[21:20:36.542] Detected Next.js version: 12.1.0
[21:20:36.544] Running "yarn run build"
[21:20:36.817] yarn run v1.22.17
[21:20:36.848] $ next build
[21:20:39.931] Generated 1 documents in .contentlayer
[21:20:39.967] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[21:20:39.967] This information is used to shape Next.js' roadmap and prioritize features.
[21:20:39.967] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[21:20:39.967] https://nextjs.org/telemetry
[21:20:39.967] 
[21:20:40.021] info  - Checking validity of types...
[21:20:46.627] warn  - No ESLint configuration detected. Run next lint to begin setup
[21:20:46.630] info  - Creating an optimized production build...
[21:20:57.127] Failed to compile.
[21:20:57.127] 
[21:20:57.128] ./.contentlayer/generated/index.mjs
[21:20:57.128] Error: error: Expected ';', got 'assert'
[21:20:57.128]  
[21:20:57.128]   |
[21:20:57.128] 7 | import allBlogPosts from './BlogPost/_index.json' assert { type: 'json' }
[21:20:57.129]   |                                                   ^^^^^^
[21:20:57.129] 
[21:20:57.129] Caused by:
[21:20:57.129]     0: failed to process js file
[21:20:57.129]     1: Syntax Error
[21:20:57.129] 
[21:20:57.129] Import trace for requested module:
[21:20:57.129] ./pages/blog/[slug].tsx
[21:20:57.129] 
[21:20:57.129] 
[21:20:57.129] > Build failed because of webpack errors
[21:20:57.196] error Command failed with exit code 1.
[21:20:57.197] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[21:20:57.223] Error! Command "yarn run build" exited with 1
[21:20:57.322] Error: Command "vercel build" exited with 1

When trying to run build locally it works fine.

I’m using:

  • “next”: “12.1.0”
  • “next-contentlayer”: “^0.2.5”
  • “contentlayer”: “^0.2.5”

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
zanilucacommented, Jul 7, 2022

@schickling yep, it worked! thank you again!

0reactions
schicklingcommented, Jul 7, 2022

Thanks a lot @zaniluca. This seems a bit odd. I was just able to reproduce the problem you described locally when running yarn build.

CleanShot 2022-07-07 at 10 49 29@2x

However, the problem disappeared after upgrading to Next.js 12.2. So I assume it was a bug in Next.js that was fixed.

CleanShot 2022-07-07 at 10 50 36@2x

Please let me know if you need further help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors – Vercel Docs
A list of errors provided by Vercel CLI or the REST API, with details on how they occur and how to resolve them....
Read more >
node-canvas runtime error · Issue #3460 · vercel ... - GitHub
Hi , I'm having a runtime error with my app that uses node-canvas@2.6.0. It doesn't uses it directly, but through the package ...
Read more >
getServerSideProps causes 500 error when deployed on vercel
When I'm running my code in localhost everything works how I want it, but when I run it on vercel it sends a...
Read more >
How to Build a Full Stack NFT Marketplace - V2 (2022)
Has anyone received the following error? ... You must provide RPC url of the testnet where you want to deploy NFT ... Expected...
Read more >
Vercel - Checkly
Installation To install Checkly's native Vercel integration, navigate to ... syntax errors in the script, or assertions using the expect or assert libraries ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found