将React组件添加到Laravel

时间:2017-02-09 20:53:25

标签: laravel reactjs gulp gulp-watch

我是Laravel的新手并做出反应,我只想在Laravel旁边使用反应组件。我按照here描述的流程进行了操作,但是当我运行gulp watch时,我收到了此错误:

C:\wamp64\www\laravel51\node_modules\laravel-elixir-webpack-react\main.js:3
Elixir.ready(function() {
   ^

TypeError: Elixir.ready is not a function
    at Object.<anonymous> (C:\wamp64\www\laravel51\node_modules\laravel-elixir-webpack-react\main.js:3:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\wamp64\www\laravel51\gulpfile.js:23:1)
    at Module._compile (module.js:570:32)

我也运行命令npm install --save-dev laravel-elixir-webpack-react但得到同样的错误。
我的package.json文件是:

{
  "private": true,
  "devDependencies": {
    "gulp": "^3.8.8",
    "laravel-elixir-webpack-official": "^1.0.10",
    "laravel-elixir-webpack-react": "^1.0.1",
    "react": "^15.4.2",
    "react-dom": "^15.4.2"
  },
  "dependencies": {
    "laravel-elixir": "^4.0.0",
    "bootstrap-sass": "^3.0.0"
  }
}

我的gulpfile是:

var elixir = require('laravel-elixir');
require('laravel-elixir-webpack-react');
elixir(function(mix) {
    mix.webpack('app.js');
});

我在Windows中使用Laravel 5.1。

0 个答案:

没有答案