V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
frontman
V2EX  ›  程序员

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

  •  
  •   frontman · 2015-07-27 16:34:53 +08:00 · 5700 次点击
    这是一个创建于 3168 天前的主题,其中的信息可能已经有所发展或是发生改变。
    安装了半天运行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   ·   我们的愿景   ·   实用小工具   ·   5177 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 09:30 · PVG 17:30 · LAX 02:30 · JFK 05:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.