使用反应和 laravel 混合时出错

Error when using react and laravel mix

当我试图对我的 laravel 项目做出反应时,我 运行 遇到了一个问题。

我在 windows 上使用 Homestead。当 ssh 进入我的虚拟服务器时,我在我的项目的根目录中,我有 运行

composer install
php artisan preset react
npm install && npm run dev

然后我收到以下错误

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN img-loader@3.0.0 requires a peer of imagemin@^5.0.0 but none was installed.
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none was installed.
npm ERR! Linux 4.4.0-92-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.11.3
npm ERR! npm  v3.10.10
npm ERR! path ../acorn/bin/acorn
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink

npm ERR! EPROTO: protocol error, symlink '../acorn/bin/acorn' -> '/home/vagrant/www/todo/node_modules/.bin/acorn'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/www/todo/npm-debug.log

在我的 assets/js/components 中添加了一个反应 example.js。

我不太确定该去哪里,所以任何帮助将不胜感激

这是在您的主机 (windows) 和 VM 之间创建符号链接时出现的问题。

首先,您不需要通过 ssh 发出这些命令,您可以安全地 运行 在您的 windows 主机上执行它们(所有更改将被静默地复制回您的 homestead VM 机器- 这就是宅基地的运作方式)

其次,根据您的 VirtualBox 安装,可能会出现一些符号链接问题。如果是这种情况,请检查您是否使用最新版本的 VirtualBox 和 Homestead。

如果还有问题,请检查这个thread