1

I am attempting to install the node.js module 'javascripting' (source code can be found: https://github.com/sethvincent/javascripting) and have been unable to install it as a global variable to run through the terminal.

After installing node.js I attempted to install javascripting with the line: npm install --global javascripting

While it is my understand that this should work, it only downloads the module but does not set it as a global variable to be run in terminal.

The error I receive when attempting to run it as a global variable is "/usr/bin/env: node: No such file or directory".

After receiving this error I attempted to move the module to /usr/bin/env from the directory it installed in (usr/local/lib/node_modules/javascripting). Unfortunately, I was not able to move the files because /usr/bin/env is not a directory, rather it seems to be some sort of executable java file (usr/bin is a directory).

I am a bit lost and would love some advice on either how to install the module as a working global variable or whether there is another way to run the module without installing it as a global variable.

J Brewer
  • 35
  • 3
  • Did you also `sudo apt-get install nodejs-legacy`? This will give you a symlink so you can use `node` in addition to `nodejs`. – mscdex Dec 17 '14 at 16:57
  • FYI /usr/bin/env is a linux binary (ELF, not Java) and sets up a specific clean environment for whatever command it calls. This can be used to make sure that a program executes the way it is intended. – stonecrusher Dec 17 '14 at 17:08

1 Answers1

1

This will happen if the node.js binary (node) is not installed in the $PATH anywhere.

if you run env node by itself, you will get the same error. It looks like this may be an Ubuntu bug: https://github.com/joyent/node/issues/3911

Try sudo ln -s /usr/bin/nodejs /usr/bin/node - that will symlink the node.js binary from the name Ubuntu gave it to the name it's supposed to have.

EDIT: As mscdex pointed out in a comment (and as mentioned at the end of the bug I linked), there's a legacy package you can install that should create this symlink.

sudo apt-get install nodejs-legacy

The bug I linked above indicates that there are probably other problems with Ubuntu / Debian's default node.js package, and recommends you install your own either from the PPA mentioned there or from source.

You'll probably need to follow the advice in NPM modules won't install globally without sudo as well.

Community
  • 1
  • 1
stonecrusher
  • 1,246
  • 10
  • 12
  • 1
    Thank you so much for the quick answers! I installed the legacy package to create the symlink as was suggested by both mscdex and stonecrusher and it worked completely. The only command needed to solve the problem was the: sudo apt-get install nodejs-legacy one cited in both posts. I greatly appreciate all of the help! Edit: per suggestion from stonecrusher I switched this to a comment rather than an answer. – J Brewer Dec 17 '14 at 17:19
  • 1
    In case you installed node via [nvm](https://github.com/creationix/nvm) then don't forget to run a `nvm use 0.x.y` or a `nvm use stable` – georg May 19 '15 at 12:33
  • Is there anyway to create symlink without root access? – beliz Nov 24 '20 at 19:34