Next.js: babel.config.js with next/babel preset-env throws "Unknown option: .preset-env"

Created on 21 Nov 2019  路  2Comments  路  Source: vercel/next.js

Question about Next.js

I'm using babel.config.js with the following presets:

 presets: [
        'next/babel', {
            'preset-env': {
                'targets': '> 0.25%',
            },
        },
        '@emotion/babel-preset-css-prop',
    ],

This is currently throwin an error trying to run the app

[ error ] ./node_modules/next/dist/client/dev/amp-dev.js
ReferenceError: [BABEL] ~REDACTED~/node_modules/next/dist/client/dev/amp-dev.js: Unknown option: .preset-env. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

Pretty sure preset-env is valid... Am I missing something?

Nextjs version : 9.0.1

Most helpful comment

This does not seem to be a bug in Next.js, please use Spectrum for questions


I guess you're simply missing additional pair of [ ] here:

 presets: [
-        'next/babel', {
+       ['next/babel', {
            'preset-env': {
                'targets': '> 0.25%',
            },
-        },
+       }],
        '@emotion/babel-preset-css-prop',
    ],

Example: https://github.com/zeit/next.js/blob/9c8d34d551e1a3729d91c86f0b62547f0d79044f/examples/custom-server-typescript/.babelrc

All 2 comments

This does not seem to be a bug in Next.js, please use Spectrum for questions


I guess you're simply missing additional pair of [ ] here:

 presets: [
-        'next/babel', {
+       ['next/babel', {
            'preset-env': {
                'targets': '> 0.25%',
            },
-        },
+       }],
        '@emotion/babel-preset-css-prop',
    ],

Example: https://github.com/zeit/next.js/blob/9c8d34d551e1a3729d91c86f0b62547f0d79044f/examples/custom-server-typescript/.babelrc

Well, that was embarassing 馃槩

Thanks! And sorry about that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jesselee34 picture jesselee34  路  3Comments

sospedra picture sospedra  路  3Comments

DvirSh picture DvirSh  路  3Comments

flybayer picture flybayer  路  3Comments

kenji4569 picture kenji4569  路  3Comments