Search code examples
node.jsbuildnpmgruntjssystem

Run a build system with Grunt


I'm trying to run a build system with grunt, but when i try to run the command npm install -g grunt-cli i get the errors in the pictures attached, i have install grunt-cli as well but i'm really lost with all that errors i got.I'm using Mac OS X,version 10.10.5 27-inch,processor 2.8 GHz intel i5. Also i have read an article how to install node and npm in mac and there i found about Homebrew but when i check for node and npm they was installed already in my mac so i'm not really sure if the errors i get has any relation with node and npm version?
thanks

enter image description here


Solution

  • run with sudo

    sudo npm install -g grunt-cli
    

    You may need to enter the password of the machine.

    Explanation If you see the errors on the terminal it reads:

    Error: EACCES: permission denied
    

    On a high level, it basically means that while executing the command the current user did not have the privilege/access to write in the dir /usr/local/lib/node_modules. Using sudo elevates the user's privilege.

    EDIT:

    if it still doesn't work try this:

    sudo chown -R $(whoami) ~/.npm
    sudo chown -R $(whoami) /usr/local/lib/node_modules
    

    then try installing grunt-cli again