Skip to content

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

@zaniluca

Description

@zaniluca

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 > [email protected]" has unmet peer dependency "date-fns@>=2.0.0".
[21:20:19.532] warning "contentlayer > @contentlayer/utils > @opentelemetry/exporter-trace-otlp-grpc > @opentelemetry/[email protected]" 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/[email protected]" 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/[email protected]" 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"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions