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.

Invalid next.config.js options detected

See original GitHub issue

next-translate: 1.5.0 next: 12.2.3

i18n.js

const hoistNonReactStatics = require('hoist-non-react-statics');

module.exports = {
  locales: ['en', 'nl'],
  defaultLocale: 'en',
  pages: {
    '*': ['common'],
  },
  loadLocaleFrom: async (lang) => {
    const commonTranslations = await import('translations');
    const appTranslations = await import('./src/translations/');

    return new Promise((resolve) =>
      resolve({ ...commonTranslations[lang], ...appTranslations[lang] })
    );
  },
  defaultNS: 'common',
  staticsHoc: hoistNonReactStatics, // required for loading custom layouts with translations
};

next.config.js

/** @type {import('next').NextConfig} */

const nextTranslate = require('next-translate');
const withTM = require('next-transpile-modules')([
  'components',
  'hooks',
]);

const nextConfig = {
  reactStrictMode: true,
};


module.exports = withTM(nextTranslate(nextConfig));

Whenever I run my app, I get following warning on my console. How can I fix this?

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

Is there something wrong with how I have configured things?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
tuncatakancommented, Jul 27, 2022

@tuncatakan yes it’s because Next.js config didn’t support those additionalProperties from next-translate.

Yes, I understand the situation. @Dragate said that he started using the new ajv validation. I guess we will wait for the new version to be released for this error to be fixed.

2reactions
Dragatecommented, Aug 6, 2022

Is there something wrong with how I have configured things?

No. Next.js has started validating its config with ajv. Currently, next-translate is injecting irrelevant information, which triggers this warning. For next.js, only locales, defaultLocale, localeDetection and domains are valid.

Culprit: https://github.com/vinissimus/next-translate/blob/7ebba0c71362b2dd349472d854730c098c793152/src/plugin/index.ts#L53

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incompatible with next.js 12.2.0: "Invalid next.config.js ... - GitHub
When compiling with next.js 12.2.0, this warning is shown, even when an empty array is passed for the plugins parameter: warn - Invalid...
Read more >
warning Invalid next.config.js when running project - nextJs
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 >
invalid-images-config - Next.js
In your next.config.js file you provided an invalid config for the images field. Possible Ways to Fix It.
Read more >
Plugins – Configuration – Intro to Next.js
The next.config.js file gives us the ability to do some powerful stuff. Because the config file has a convention, you should be able...
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 >

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