laravel8 使用 Yarn 安装依赖报错?该怎么解决呢?

一,laravel8,跟着教程做,
执行$ SASS_BINARY_SITE=npm.taobao.org/mirrors/node-sass yarn报如下警告:

vagrant@homestead:~/Code/weibo$ SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass yarn
yarn install v1.19.0
info No lockfile found.
[1/4] Resolving packages...
warning laravel-mix > @types/browser-sync > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning laravel-mix > @types/autoprefixer > @types/browserslist@4.15.0: This is a stub types definition. browserslist provides its own type definitions, so you do not need this installed.
warning laravel-mix > @types/browser-sync > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning laravel-mix > @types/browser-sync > chokidar > braces > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning laravel-mix > @types/browser-sync > chokidar > braces > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[2/4] Fetching packages...
info fsevents@2.3.1: The platform "linux" is incompatible with this module.
info "fsevents@2.3.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 43.98s.

二,执行$ npm run watch-poll 报错如下:

vagrant@homestead:~/Code/weibo$ npm run watch-poll

> @ watch-poll /home/vagrant/Code/weibo
> mix watch -- --watch-options-poll=1000

Error: You are using an unspported version of Node. Please update to at least Node v12.14
    at assertSupportedNodeVersion (/home/vagrant/Code/weibo/node_modules/laravel-mix/src/Engine.js:6:15)
    at executeScript (/home/vagrant/Code/weibo/node_modules/laravel-mix/bin/cli.js:58:5)
    at Command.<anonymous> (/home/vagrant/Code/weibo/node_modules/laravel-mix/bin/cli.js:36:13)
    at Command.listener [as _actionHandler] (/home/vagrant/Code/weibo/node_modules/laravel-mix/node_modules/commander/index.js:426:31)
    at Command._parseCommand (/home/vagrant/Code/weibo/node_modules/laravel-mix/node_modules/commander/index.js:1002:14)
    at Command._dispatchSubcommand (/home/vagrant/Code/weibo/node_modules/laravel-mix/node_modules/commander/index.js:953:18)
    at Command._parseCommand (/home/vagrant/Code/weibo/node_modules/laravel-mix/node_modules/commander/index.js:970:12)
    at Command.parse (/home/vagrant/Code/weibo/node_modules/laravel-mix/node_modules/commander/index.js:801:10)
    at Command.parseAsync (/home/vagrant/Code/weibo/node_modules/laravel-mix/node_modules/commander/index.js:828:10)
    at run (/home/vagrant/Code/weibo/node_modules/laravel-mix/bin/cli.js:47:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch-poll: `mix watch -- --watch-options-poll=1000`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ watch-poll script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2021-02-01T11_40_16_228Z-debug.log

折腾了几天了,npm也试过了,Mac和Windows都会报错,laravel7好像可以执行成功。laravel8实在是不知道怎么解决,有会解决的朋友,可以评论取留言。
@Summer

懒惰的大叔
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 11

sudo apt update && sudo apt install nodejs

3年前 评论
懒惰的大叔 (楼主) 3年前
SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass yarn
yarn add cross-env

homestead 升级 nodejs:

sudo apt update
sudo apt install nodejs
3年前 评论
Summer

homestead 的 nodejs 需要升级了,我今天去处理下

3年前 评论
懒惰的大叔 (楼主) 3年前
懒惰的大叔 (楼主) 3年前

兄弟,这个问题我都被虐了半个月了都没解决。。。。。。

3年前 评论
jxdr 3年前
何雨 3年前
laravel_peng

看了 N 多评论,再根据自己的情况!最终终于解决!
每个人的情况不一样 还是不要直接粘贴别人的 理解了 Npm 和 Yarn 在做什么 可以更快的解决问题!
记录下自己解决 BUG 的过程 本人配置(Windows 10 新系统 教程版 Homestead)
因为第一次报错了 所有我先重置了所有相关文件

rm -rf node_modules
rm -rf yarn.lock
npm cache clear --force

然后重新安装(求稳,都使用了 sudo 命令)

yarn install --no-bin-links

打开 package.json 搜索字符串 cross-env 并删除

sudo yarn add cross-env --save --no-bin-links
sudo npm install vue-template-compiler --save-dev --production=false --no-bin-links
sudo npm run dev
sudo npm run watch-poll

到此结束 倒腾了 1 个多小时 终于搞定!Over!
附上链接:分享:新手怎么解决 NPM run dev 报错的问题,综合回答一下,希望能帮到后...

2年前 评论
kakaxi 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!