2

I have recently attempted to install Node JS to have a local development environment. However, after following the step by step directions, I can not actually compile a '.js' file yet. Rather, I get the following error:

-bash: /usr/local/nodejs/bin/node: cannot execute binary file

I have searched extensively for a solution and the only hint I could find was that maybe my path is messed up. I have included that as well...

/usr/local/nodejs/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/usr/local/nodejs/bin:/usr/local/nodejs/bin

Any help would be greatly appreciated! Thanks!

5
  • check the file permissions on /usr/local/nodejs/bin/node and make sure it has executable permissions. (and if it's a symlink, make sure the symlink and the target location are executable). Commented Feb 27, 2016 at 20:41
  • What command are you running? Node.js is Javascript, and it's not compiled, it's interpreted at runtime. Commented Feb 27, 2016 at 20:42
  • are you sure the NodeJS installation went fine? Commented Feb 27, 2016 at 20:44
  • Farside - I believe so, the entire install runs smoothly and everything is where it belongs. Commented Feb 27, 2016 at 21:24
  • Svenskunganka - I am running "node main.js" sorry for any confusion. Commented Feb 27, 2016 at 21:31

2 Answers 2

1

sudo ln -s /usr/bin/node /usr/bin/nodejs

Its a common problem, always solved by creating a symlink.

Don't install with apt-get the package 'node', it's not the same thing.

Sign up to request clarification or add additional context in comments.

4 Comments

After the command I am prompted for my password which further tells me the operation is not permitted.
@CoachFlaps: what is your current OS ? Linux ubuntu ? Linux Mint ? Mac OS X ? you have to find the password or ask the real user of the computer to execute that.
My current OS X El Capitan 10.11, I know the password. If i get it wrong is says you have the wrong password. If i get it right it says "the operation is not permitted."
under Mac OS X there is a procedure to find the 'root' account of the terminal.
0

Issue has been resolved. My fix was uninstalling the Node JS I currently had installed and then reseting the path of my bash profile. After resetting it, I then reassigned it to where I had my new Node JS installed. I also recommend getting Node JS from their website as a package download rather than installing via terminal. It is a controlled install that tells you exactly where everything went.

My underlying issue was the path. It was pointing to the same place multiple times and then somewhere else that didn't exist anymore.

Thanks to all who tried to assist me!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.