Getting babel build errors with the next.js getting started example

1.7k views Asked by At

Following along the getting started example from ZEIT for next.js, I'm getting this error:

error  in ./pages/index.js

Module build failed: ReferenceError: [BABEL] /Users/Projects/nextDemo/pages/index.js: Using removed Babel 5 option: /Users/Projects/.babelrc.optional - Put the specific transforms you want in the `plugins` option

What is this error - is it trying to use my globally installed babel? Is there a version mismatch or an update I should be doing?

This is the basic steps I did to get here:

$ npm install next --save
$ mkdir pages

//pages/index.js:
import React from 'react'
export default () => <div>Hello world!</div>

Add a script to the package.json like this:
{
  "scripts": {
    "dev": "next"
  }
}

$ npm run dev

and the installed packages:

└─┬ [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  ├── [email protected]
  └── [email protected]
1

There are 1 answers

1
Rudi On

It uses your .babelrc file from the parent directory because:

Babel will look for a .babelrc in the current directory of the file being transpiled. If one does not exist, it will travel up the directory tree until it finds either a .babelrc, or a package.json with a "babel": {} hash within.

Use "babelrc": false to stop lookup behavior.