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.

next.config.js ajv verification: analyticsId - must NOT have additional properties

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

    Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 18.4.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 12.2.3
      eslint-config-next: 12.2.3
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

chrome

How are you deploying your application? (if relevant)

next start

Describe the Bug

seems next 12.2.3 do now validates next.config.js with ajv (https://github.com/vercel/next.js/pull/38498).

As I’m using vercel analytics on my non-vercel deployments, I need to hand in the analyticsId property to next.config.js.

/**
 * @type {import('next').NextConfig}
 **/
const config = {
  trailingSlash: false, // disable trailing slashes.
  poweredByHeader: false, // disable powered by header.
  reactStrictMode: true, // set strict mode for react.
  swcMinify: true, // minify using swc/rust.
  compress: false, // let nginx handle compression.
  analyticsId: "MY_ANALYTICS_ID", // vercel analytics id.

and at the very startup next 12.2.3 now warns about the analyticsId property:

warn  - Invalid next.config.js options detected:
[
  {
    "instancePath": "",
    "schemaPath": "#/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "analyticsId"
    },
    "message": "must NOT have additional properties"
  }
]
See more info here: https://nextjs.org/docs/messages/invalid-next-config

Expected Behavior

allow analyticsId property without a warning.

Link to reproduction

.

To Reproduce

add analyticsId from vercel to next.config.js.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

15reactions
tatwatercommented, Jul 22, 2022

Getting this same error when using next-pwa! In this case, the additionalProprty it doesn’t like is "pwa"

1reaction
amaralccommented, Jul 29, 2022

Same issue here when using NX and exportPathMap:



warn  - Invalid next.config.js options detected:
--
[
  {
    "instancePath": "",
    "schemaPath": "#/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
    "additionalProperty": "nx"
  },
  "message": "must NOT have additional properties"
  },
  {
    "instancePath": "",
    "schemaPath": "#/additionalProperties",
    "keyword": "additionalProperties",
    "params": {
      "additionalProperty": "exportPathMap"
    },
    "message": "must NOT have additional properties"
  }
]

Read more comments on GitHub >

github_iconTop Results From Across the Web

next.config.js must NOT have additional properties
It finally seems that Next.js just wanted an update and a small refactor in next.config.js.. So, now it looks like this without any...
Read more >
Ajv options - Ajv JSON schema validator
This page describes properties of the options object that can be passed to Ajv ... It does not change any validation results, but...
Read more >
the request of a dependency is an expression nextjs - You.com
1- warn - Invalid next.config.js options detected: The root value has an unexpected property, webpack5, which is not in the list of allowed...
Read more >
Validating JSON with ajv - YouTube
Validating JSON with ajv in node. js and browser projects. Another json validator is a very good library todo so. It allows you...
Read more >
JSON-Schema everywhere. How to make web development ...
The data can contain the other properties defined under the ... We will use a very popular JSON-Schema-Validation library named AJV which is...
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