[Babel]:未知选项:foreign.Children

时间:2016-08-08 17:58:49

标签: javascript reactjs npm webpack babeljs

我在使用此脚本构建时遇到错误:

webpack --colors --progress --watch --config --jsx-loader webpack.config.js

这是我的package.json文件:

{
  "dependencies": {
    "autoprefixer": "^6.0.3",
    "node-libs-browser": "^0.5.3",
    "object-assign": "4.0.1",
    "underscore": "1.8.3",
    "react": "0.14.7",
    "react-dom": "0.14.7",
    "react-router": "2.0.0",
    "history": "^1.17.0",
    "superagent": "^1.8.0",
    "react-addons-css-transition-group": "0.14.7",
    "react-bootstrap": "0.28.2",
    "react-select": "^1.0.0-beta9",
    "moment": "2.11.2",
    "truncate": "2.0.0",
    "superagent-promise-plugin": "2.1.0",
    "rrule": "2.1.0"
  },
  "devDependencies": {
    "babel-core": "^6.13.2",
    "babel-loader": "^6.2.4",
    "babel-preset-es2015": "^6.13.2",
    "babel-preset-stage-0": "^6.5.0",
    "babel-runtime": "^6.11.6",
    "css-loader": "^0.23.1",
    "eslint": "^3.2.2",
    "eslint-config-defaults": "^9.0.0",
    "eslint-loader": "^1.5.0",
    "eslint-plugin-react": "^6.0.0",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.9.0",
    "html-webpack-plugin": "^2.22.0",
    "isparta-instrumenter-loader": "^1.0.1",
    "jsx-loader": "0.13.2",
    "less": "^2.3.1",
    "less-loader": "^2.2.3",
    "livereload": "^0.5.0",
    "null-loader": "^0.1.1",
    "postcss-loader": "^0.9.1",
    "raw-loader": "^0.5.1",
    "style-loader": "^0.13.1",
    "webpack": "^1.12.13",
    "webpack-livereload-plugin": "0.4.0"
  },
  "babel": {
    "presets": [
      "stage-0",
      "es2015",
      "react"
    ]
  }
}

我的webpack.config.js

var webpack = require('webpack');
var path = require('path');
var LiveReloadPlugin = require('webpack-livereload-plugin')

module.exports = {
    output: {
        path: __dirname,
        filename: "bundle.js",
    },
    resolve: {
        extensions: ['', '.js', '.jsx'],
        root: [
          path.resolve('./../../../../../../Javascripts/modules')
        ],
        moduleDirectories:
        [
          './../../../../../../Javascripts/modules'
        ]
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" },
            {
                test: /\.less$/,
                loader: "style!css!less"
            },
            { test: /\.html$/, loader: 'raw', exclude: [/node_modules/, path.resolve('./../../../../../../Javascripts/modules')] },
            {
                test: /(\.jsx|\.js)$/,
                loader: 'babel',
                exclude: [/(node_modules|bower_components)/]
            },
            {
                test: /(\.jsx|\.js)$/,
                loader: "eslint-loader",
                exclude: [/node_modules/, path.resolve('./../../../../../../Javascripts/modules')]
            }
        ]
    },
    eslint: {
        configFile: './src/js/.eslintrc'
    },
    entry: "./src/index.js",
    plugins: [
        new LiveReloadPlugin()
    ]
};

知道如何解决该错误吗?根据我的Google搜索,它是一个软件包版本控制问题,但这是我能够弄清楚的。

2 个答案:

答案 0 :(得分:28)

你可能会错过反应babel预设npm包。

试试这个:

npm i --save-dev babel-preset-react

答案 1 :(得分:-1)

我最终回到Babel 5,这个问题消失了。对于那些稍后可能会发现这个问题的人来说,这不是一个很好的答案,但它适用于我的应用程序。