“Fatal error: Unable to find local grunt.” when running “grunt” command

前端 未结 7 448
猫巷女王i
猫巷女王i 2021-01-30 08:11

I uninstalled grunt with following command.

npm uninstall -g grunt

Then I again installed grunt with following command.

npm ins         


        
7条回答
  •  庸人自扰
    2021-01-30 08:46

    This solved the issue for me. I mistakenly installed grunt using:

    sudo npm install -g grunt --save-dev
    

    and then ran the following command in the project folder:

    npm install
    

    This resulted in the error seen by the author of the question. I then uninstalled grunt using:

    sudo npm uninstall -g grunt
    

    Deleted the node_modules folder. And reinstalled grunt using:

    npm install grunt --save-dev
    

    and running the following in the project folder:

    npm install
    

    For some odd reason when you global install grunt using -g and then uninstall it, the node_modules folder holds on to something that prevents grunt from being installed locally to the project folder.

提交回复
热议问题