Node.js bash: /usr/local/bin/node: Permission denied

36,444

Solution 1

You need read- and executable permissions for others. Issue:

sudo chmod +rx $(which node)

or

sudo chmod 755 $(which node)

However, normally make install should set that permissions. Looks like something in the Makefile is wrong.

Solution 2

For people with no knowledge of osx terminal, open it and use these commands:

su yourusername
su chmod 755 /usr/local/bin/node
sudo node install...

This will make the folder readable/writeable and the sudo before the node command will make it run under admin rights.

Share:
36,444
demi
Author by

demi

I work for Google, love functional programming and Clojure, but code in C++, Java and JS.

Updated on July 13, 2022

Comments

  • demi
    demi almost 2 years

    I'm installing Node.js on Ubuntu machine. I followed official instructions:

    ./configure && make && sudo make install
    

    So, I got node binary in /usr/local/bin/node and all dependencies. But when I run it from command line I get permission error:

    > node
    bash: /usr/local/bin/node: Permission denied
    

    How can I fix it? How can I run it under my account? sudo node doesn't work too.

  • hek2mgl
    hek2mgl over 10 years
    Thx :) The whole GNU userland is fantastic! Can't stop loving it :)
  • demi
    demi over 10 years
    I have node executable for the user (see comment under answer about ls -l). For me, chown worked (it was root root as you can see). chmod didn't help.
  • hek2mgl
    hek2mgl over 10 years
    Binaries (or scripts) located in /usr/local/bin are expected to be owned by root, group root and having permissions set to 755. That's standard. I'm not sure what you are doing there.
  • hek2mgl
    hek2mgl over 10 years
    Also I expect that make install will install to /usr/bin and not /usr/local/bin. Maybe you have an old node binary residing in /usr/local/bin which get's executed (or makes trouble) instead of the previously installed binary by make install (to /usr/bin) ?
  • Ar5hv1r
    Ar5hv1r almost 9 years
    I ran into this error after having run +x, turned out others didn't have read access and it needs both. So 755 (or +xr) might be necessary if +x is insufficient.
  • hek2mgl
    hek2mgl almost 9 years
    @dimo414 Thanks. I've edited that. When posting the answer I assumed read permissions had been granted already.
  • JRichardsz
    JRichardsz almost 8 years
    In my case I knew node binarie path, so : sudo chmod +rx /apps/.../node-v4.2.3-linux-x64/bin/node works!! THanks hek2mgl
  • JD Smith
    JD Smith about 4 years
    Worked for me with my custom node install in SAP Hybris. Thank you!
  • JD Smith
    JD Smith about 4 years
    FYI "su chmod..." didn't work for me in my Mac - I had to do "sudo chmod..."