公告:“业余草”微信公众号提供免费CSDN下载服务(只下Java资源),关注业余草微信公众号,添加作者微信:xttblog2,发送下载链接帮助你免费下载!
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序
腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序
腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云
最近的跑一个 nodejs 项目时遇到了问题,很多前端都不知道如何下手解决!
我这个后端老司机,无奈之下,一顿百度谷歌,最终找到解决方案。前端也并不是不可跨越的。。。
错误产生的原因是,项目中配置了 cross-env APP_TYPE=site PORT=8888 umi dev。
{
"name": "业余草",
"version": "2.5.2",
"description": "An out-of-box UI solution for enterprise applications",
"private": true,
"scripts": {
"presite": "cd functions && npm install",
"start": "cross-env APP_TYPE=site PORT=8888 umi dev"
// ....
}
}
然后在运行 npm run dev 时报错了。
> Code@1.0.0 dev /User/xtt/Code
> cross-env APP_TYPE=site PORT=8888 umi dev
sh: 1: cross-env: not found
npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.8.0
npm ERR! npm v4.2.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! Code@1.0.0 dev: `cross-env APP_TYPE=site PORT=8888 umi dev`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the Code@1.0.0 dev script 'cross-env APP_TYPE=site PORT=8888 umi dev'.
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 Code package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env APP_TYPE=site PORT=8888 umi dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Code
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Code
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /User/xtt/.npm/_logs/2020-04-28T17_24_11_458Z-debug.log
解决办法很简单,安装一下 cross-env 即可。
npm install cross-env --save-dev
最后,欢迎关注我的个人微信公众号:业余草(yyucao)!可加作者微信号:xttblog2。备注:“1”,添加博主微信拉你进微信群。备注错误不会同意好友申请。再次感谢您的关注!后续有精彩内容会第一时间发给您!原创文章投稿请发送至532009913@qq.com邮箱。商务合作也可添加作者微信进行联系!
本文原文出处:业余草: » sh: cross-env: command not found 问题修复