What is causing this error - “Fatal error: Unable to find local grunt”

前端 未结 13 560
夕颜
夕颜 2020-11-27 09:21

I removed the old version of grunt first, then I installed the new grunt version, and then I got this error:

D:\\www\\grunt-test\\grunt grunt-cli: The

相关标签:
13条回答
  • 2020-11-27 09:35

    If you already have a file package.json in the project and it contains grunt in dependency,

      "devDependencies": {
        "grunt": "~0.4.0",
    

    Then you can run npm install to resolve the issue

    0 讨论(0)
  • 2020-11-27 09:39

    I had the same issue in Vagrant.

    I have used sudo to run the command to install.

    sudo npm install -g grunt-cli
    

    It worked for me.

    0 讨论(0)
  • 2020-11-27 09:42

    Being new to grunt and setting it up, I am running (perhaps foolishly) my grunt project/folder from a Google Drive so I can access the same code/builds from either my laptop or workstation.

    There is a fair bit of synchronisation of the nodes_modules folders back to Google Drive and there seemed to be a conflict at some point, and the /nodes_modules/grunt folder was renamed to /nodes_modules/grunt (1)

    Renaming it back by removing the (1) seemed to fix it for me.

    0 讨论(0)
  • 2020-11-27 09:49

    I had to execute the following commands on ubuntu to solve this problem (I know grunt for 1 hour) :

    sudo npm install -g grunt
    sudo npm install -g grunt-cli
    
    cd /usr/local/bin
    # current symlink points to ../lib/node_modules/grunt/bin/grunt*
    sudo rm /usr/local/bin/grunt
    sudo ln -s ../lib/node_modules/grunt-cli/bin/grunt* grunt
    

    It is dirty but it is the only one solution I found... :(

    0 讨论(0)
  • 2020-11-27 09:51

    Do

    npm install
    

    to install Grunt locally in ./node_modules (and everything else specified in the package.json file)

    0 讨论(0)
  • 2020-11-27 09:53

    You can simply run this command:

    npm install grunt --save-dev
    
    0 讨论(0)
提交回复
热议问题