Search This Blog

/usr/bin/env: node: No such file or directory


The Problem


You have installed npm or nodejs and the second you go to use it you receive an error message:

/usr/bin/env: node: No such file or directory

The Cause


Package managers. *sigh* What is normally named node is named nodejs.

$ which nodejs
/usr/bin/nodejs


The Solution


[ -d ~/bin ] || mkdir ~/bin
ln -s $(which nodejs) ~/bin/node

This will allow your system to find node.

There must be some reason behind the package maintainers renaming node to nodejs, probably to avoid a conflict, so you don't really want to be renaming files, or making the changes system-wide (/usr/local/bin) unless you know what you are doing.

$ node --help
Usage: node [options] [ -e script | script.js ] [arguments]
node debug script.js [arguments]

Options:
-v, --version print node's version
-e, --eval script evaluate script
-p, --print evaluate script and print result
-i, --interactive always enter the REPL even if stdin
does not appear to be a terminal
--no-deprecation silence deprecation warnings
--trace-deprecation show stack traces on deprecations
--v8-options print v8 command line options
--max-stack-size=val set max v8 stack size (bytes)

Environment variables:
NODE_PATH ':'-separated list of directories
prefixed to the module search path.
NODE_MODULE_CONTEXTS Set to 1 to load modules in their own
global contexts.
NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL

Documentation can be found at http://nodejs.org/


Great stuff!

References:
https://github.com/nodejs/node-v0.x-archive/issues/3911#issuecomment-8956154
VigLink badge My profile on StackExchange