安装 grunt.js 的时候 一直出现 Fatal error: Unable to find local grunt. - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
frontman
V2EX    程序员

安装 grunt.js 的时候 一直出现 Fatal error: Unable to find local grunt.

  •  
  •   frontman 2015-07-27 16:34:53 +08:00 6284 次点击
    这是一个创建于 3731 天前的主题,其中的信息可能已经有所发展或是发生改变。
    安装了半天运行gurnt的时候都是出现下面这段提示
    grunt-cli: The grunt command line interface. (v0.1.13)

    Fatal error: Unable to find local grunt.

    If you're seeing this message, either a Gruntfile wasn't found or grunt
    hasn't been installed locally to your project. For more information about
    installing and configuring grunt, please see the Getting Started guide:

    http://gruntjs.com/getting-started

    各种搜 重新安装也是
    全局安装 sudo npm install -g grunt-cli
    工作目录下安装 npm install grunt --save-dev

    请问大神怎么搞
    10 条回复    2015-07-28 16:18:57 +08:00
    airyland
        1
    airyland  
       2015-07-27 16:45:46 +08:00
    Gruntfile.js创建了吗?
    frontman
        2
    frontman  
    OP
       2015-07-27 16:47:32 +08:00
    @airyland 创建了
    xiao17
        3
    xiao17  
       2015-07-27 16:48:51 +08:00
    * which node 看看node安在哪了
    * which grunt 看看grunt 安在哪了
    * 不要用sudo 安装node, 不要问为什么
    * 不要用sudo 安装grunt,你可以配置下.npmrc 指定 prefix = ~
    * 推荐使用nvm 安装node,不要问为什么
    + https://github.com/creationix/nvm
    * 推荐使用gulp,而不使用grunt,gulp 基于流的,grunt基于文件的慢
    SoloCompany
        4
    SoloCompany  
       2015-07-27 18:15:33 +08:00
    先 sudo npm -g grunt-cli
    FrankFang128
        5
    FrankFang128  
       2015-07-27 18:25:25 +08:00
    快换 gulp
    ChefIsAwesome
        6
    ChefIsAwesome  
       2015-07-27 18:37:58 +08:00 via Android
    grunt真的很蛋疼。其实好多东西用webpack加上自己写的小脚本就够了。gulp,grunt都可以不用
    yangg
        7
    yangg  
       2015-07-27 18:44:31 +08:00
    把 /usr/local/bin加到环境变量。
    arzusyume
        8
    arzusyume  
       2015-07-27 18:46:42 +08:00
    项目中也要npm install grunt
    我刚试着把 node_modules/grunt 删掉就会报这个
    martianyi
        9
    martianyi  
       2015-07-27 21:57:13 +08:00
    1. 你的系统环境是windows,ubuntu还是mac?不同系统情况会稍有不同,问的时候最好把情况描述清楚。
    2.看看你的项目目录里有没有node_modules文件夹,里面有没有grunt,这个错误提示在你的项目里没有找到grunt。
    3.你说你有Gruntfile.js, 在你的Gruntfile.js里有没有配置任务,或者你配置了任务,有没有安装相应的grunt包(比如配置concat任务需要grunt-contrib-concat)?
    4.从头到尾把grunt的文档好好看一遍,这种问题你自己是可以找到答案的,如果英文不好当我没说。
    frontman
        10
    frontman  
    OP
       2015-07-28 16:18:57 +08:00
    @yangg 怎么添加
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1418 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 24ms UTC 16:55 PVG 00:55 LAX 09:55 JFK 12:55
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86