在 Homestead 中 执行 yarn add cross-env 报错,无法成功执行,该怎么做?

根据教程,在执行 yarn add cross-nav 的时候会报错。

$ yarn add cross-env --no-bin-install
yarn add v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
error An unexpected error occurred: "EPROTO: protocol error, symlink '../acorn/bin/acorn' -> '/home/vagrant/code/homestead.test/node_modules/acorn-dynamic-import/node_modules/.bin/acorn'".
info If you think this is a bug, please open a bug report with the information provided in "/home/vagrant/code/homestead.test/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

我想还是和虚拟机的 symbol-link 有关,所以抱着侥幸心理带上 --no-bin-links 参数尝试了一次……结果如我所料并没有卵用。
求懂的人赐教。

附言 1  ·  6年前

没办法,最后使用了 cnpm 才弄好。
本地安装 npm 和 cnpm。
使用 cnpm installcnpm install cross-env --save 代替教程提供的 yarn install --no-bin-linksyarn add cross-env 才成功的。

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 9
oyghan

在package.json文件中的scripts配置中删掉cross-env依赖就好了。

5年前 评论

@oyghan 是把"development", "hot", "production"三项里面最前面的"cross-env"删掉吗?试过了还是报错啊

5年前 评论

把所有东西关闭退出,然后以管理员身份运行git,再输入相关命令

5年前 评论
Yongcheng 4年前
linkin18782003 4年前
jimmyTu 4年前
luxiaofeng 3年前

An unexpected error occurred: "EPROTO: protocol error, symlink '../../../parser/bin/babel-parser.js' -> '/home/vagrant/Code/MaLi/node_modules/@babel/core/node_modules/.bin/parser'"
我跟你的特别像,可是根本搜不到怎么解决,大佬有办法吗?

5年前 评论
chenlulinlin 4年前
bing_ 4年前

@Baoyuan 你用的是 homestead 开发环境吧。我后面才发现是 symbol link 的原因,好像是软连接在文件同步中除了问题。后来在本地自己搭建环境,或者完全使用 linux 搭建环境开发,就再没遇到这样的问题。

5年前 评论

@Baoyuan 我的问题跟你的一样,
error in ./resources/sass/app.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
NoSuchMethodError: method not found: 'pathToFileURL' (url.pathToFileURL is not a function)
我win10用的教程里的虚拟机,请问你问题解决了吗?如果解决了,请教我一下。我卡这很久了。

4年前 评论

我也一样。卡一天了。。。

3年前 评论

我找到问题所在了: 修改去掉 scripts 字段中的全部 cross-env。因为虚拟机为 Linux 环境,不需要 cross-env,否则会各种报错。

3年前 评论

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