简体   繁体   English

使用next.js入门示例获取babel构建错误

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

Following along the getting started example from ZEIT for next.js, I'm getting this error: 遵循ZEIT的next.js入门示例,出现此错误:

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? 这是什么错误-尝试使用我全局安装的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: 和已安装的软件包:

└─┬ next@1.2.3
  ├── ansi-html@0.0.6
  ├── babel-core@6.18.2
  ├── babel-generator@6.19.0
  ├── babel-loader@6.2.8
  ├── babel-plugin-module-resolver@2.4.0
  ├── babel-plugin-react-require@3.0.0
  ├── babel-plugin-transform-async-to-generator@6.16.0
  ├── babel-plugin-transform-class-properties@6.19.0
  ├── babel-plugin-transform-object-rest-spread@6.19.0
  ├── babel-plugin-transform-runtime@6.15.0
  ├── babel-preset-es2015@6.18.0
  ├── babel-preset-react@6.16.0
  ├── babel-runtime@6.18.0
  ├── cross-spawn@5.0.1
  ├── del@2.2.2
  ├── domready@1.0.8
  ├── friendly-errors-webpack-plugin@1.1.1
  ├── glamor@2.20.8
  ├── glob-promise@2.0.0
  ├── htmlescape@1.1.1
  ├── is-windows-bash@1.0.2
  ├── json-loader@0.5.4
  ├── loader-utils@0.2.16
  ├── minimist@1.2.0
  ├── mkdirp-then@1.2.0
  ├── mz@2.6.0
  ├── path-match@1.2.4
  ├── react@15.4.1
  ├── react-dom@15.4.1
  ├── react-hot-loader@3.0.0-beta.6
  ├── read-pkg-up@2.0.0
  ├── send@0.14.1
  ├── source-map-support@0.4.6
  ├── strip-ansi@3.0.1
  ├── url@0.11.0
  ├── webpack@1.13.3
  ├── webpack-dev-middleware@1.8.4
  ├── webpack-hot-middleware@2.13.2
  └── write-file-webpack-plugin@3.4.2

It uses your .babelrc file from the parent directory because: 它使用父目录中的.babelrc文件, 因为:

Babel will look for a .babelrc in the current directory of the file being transpiled. Babel将在要编译的文件的当前目录中查找.babelrc。 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. 如果不存在,它将沿目录树向上移动,直到找到.babelrc或其中带有“ babel”:{}哈希值的package.json。

Use "babelrc": false to stop lookup behavior. 使用“ babelrc”:false停止查找行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM