'foreign'中指定的插件0提供了'_c'的无效属性

时间:2016-08-26 05:23:50

标签: reactjs babeljs graphql relay

使用以下配置获得上述错误,我该如何使其正常工作?

.babelrc:

namespace Ghunti\HighchartsPHP;
use Ghunti\HighchartsPHP\HighchartOption;
use Ghunti\HighchartsPHP\HighchartOptionRenderer;

package.json:

<?php

App::import('Vendor','HighchartsPHP', array('file'=>'HighchartsPHP'.DS.'Highchart.php'));

//App::import('Vendor', 'HighchartsPHP/Highchart');

class GraficasController extends AppController {
    public function index() {  
        $chart = new Highchart();
        $chart->chart = array(
            'renderTo' => 'container', // div ID where to render chart
            'type' => 'line'
        );
        $chart->series[0]->name = 'Tokyo';
        $chart->series[0]->data = array(7.0, 6.9, 9.5);
        $this->set( compact( 'chart' ) );
    }
}
?>

server.js:

{
  "passPerPreset": true,
  "presets": [
    {"plugins": ["./build/babelRelayPlugin"]},
    "react",
    "es2015",
    "stage-0"
  ]
}

终端错误:babel-node server.js

./js/app.js中的错误
模块构建失败:错误:'foreign'中指定的插件0提供了'_c'

的无效属性

浏览器错误:localhost:3000

控制台窗口中的

Uncaught Invariant Violation:RelayQL:运行时意外调用。未设置Babel转换,或者无法识别此呼叫站点。确保将其逐字逐句用作{ "name": "1", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "babel-core": "^6.14.0", "babel-loader": "^6.2.5", "babel-polyfill": "^6.13.0", "babel-preset-es2015": "^6.14.0", "babel-preset-react": "^6.11.1", "babel-preset-stage-0": "^6.5.0", "babel-relay-plugin": "^0.9.2", "express": "^4.14.0", "express-graphql": "^0.5.3", "graphql": "^0.6.2", "graphql-relay": "^0.4.2", "react": "^15.3.1", "react-dom": "^15.3.1", "react-relay": "^0.9.2", "webpack": "^1.13.2", "webpack-dev-server": "^1.15.0" }, "devDependencies": { "babel-cli": "^6.14.0" } }

1 个答案:

答案 0 :(得分:2)

我使用以下设置取得了成功。我在我的webpack模块中使用带有babel加载器的插件而不是.babelrc

在webpack中:

query: {
  presets: [
    "es2015", "react", "stage-0", {
      "plugins": [
        "./schema-build/babelRelayPlugin"
      ]
    }
  ]
}

在.babelrc:

{
  "passPerPreset": true,
  "presets": [
    "react",
    "es2015",
    "stage-0"
  ]
}