输入 yarn add cross-env 后报错,无法继续,怎么办?

输入 yarn add cross-env 后报错
vagrant@homestead:~/Code/sample$ yarn add cross-env
yarn add v0.27.5
warning ../../package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
warning 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/sample/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/sample/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

如果在这之后输入 npm run dev 也报错
vagrant@homestead:~/Code/sample$ npm run dev

@ dev /home/vagrant/Code/sample
npm run development

@ development /home/vagrant/Code/sample
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: 1: cross-env: not found

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "development"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ development: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ development script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.

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

npm ERR! Linux 4.4.0-81-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: npm run development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.

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

卡在这了,无法继续

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
MengCY
最佳答案

@Chris_Sun windows下删除package.json下的4处cross-env,如图所示,

file
跳过它即可。

6年前 评论
讨论数量: 17
MengCY

@Chris_Sun windows下删除package.json下的4处cross-env,如图所示,

file
跳过它即可。

6年前 评论
MengCY

@Chris_Sun windows下删除package.json下的4处cross-env,如图所示,

file
跳过它即可。

6年前 评论

全局安装 cross-env
npm install cross-env -g

6年前 评论

@MengCY 在windows下使用yarn add cross-env这个命令安报错后,把package.json中的cross-env都删除了,再次执行还是后报错。是什么原因啊?

6年前 评论

刚才忘记贴图了,现在贴出来

file

6年前 评论
小花儿

同样的问题啊,请问楼主解决了吗?

6年前 评论

@ethanCheng 更新一下: 是删除 cross-env 字符, 而不是整行

6年前 评论

同楼主一样 删除完依旧报错

6年前 评论

我也是删除 cross-env 字符,然报错,关了所有, git-bash 以管理员身份运行 ,执行所有命令,没有报错了

6年前 评论

@MengCY 删除了,跳过这步“yarn add cross-env”命令不执行吗,我这样试了可后面的命令npm run dev就报错

6年前 评论

@ethanCheng 我也是给这问题卡了好几天了,请问下你解决了吗,麻烦指导一下

6年前 评论

@Koke_Cacao 为什么我删除了还是报错,被这问题卡了好几天了,能不能帮指导一下

6年前 评论

@beifeng 试着重新安装之前安装的包? 发一下你配置文件截图?

6年前 评论

@Koke_Cacao 配置包和你上面截图一样的了,我是完全按教程的一步步跟着来的,重试了几次了,甚至把虚拟机都删了重新从头来一遍也是这样,网上查资料有人说yarn add cross-env 这一命令对教程里的虚拟机没啥用,还说如果是在WINDOWS下跑的就要这命令,

6年前 评论

可以先把node_modules删除,然后cnpm install cross-env --save-dev,之后cnpm install,
这两天一直遇到这个问题,解决过程中记得好像是报包冲突的错误,然后这样操作了下,就好了,可以试试

6年前 评论

也出现了这个问题,不知道咋办

5年前 评论
Vicer

@岛鬼 说的是正确的,照做我也成功了

原话:我也是删除 cross-env 字符,然报错,关了所有, git-bash 以管理员身份运行 ,执行所有命令,没有报错了

5年前 评论
bing_ 4年前
Vicer (作者) 4年前
bing_ 4年前
levin29 4年前

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