2

I just installed coffe script with NPM (sudo npm install -g coffee-script)

When I type coffee into my terminal nothing happens. The command is found but does not show any reaction.

Does anyone know how to fix that or could have gone wrong?

4

Apparently npm coffee script is broken. I've tried in my system using both, global and local installation and do not work. Luckily you can use coffeescript package from apt-get:

sudo apt-get install coffeescript

In my case installed version 1.4.0. Is a fair price for having something working:

coffee --version
CoffeeScript version 1.4.0
  • Thanks for your answer. In my case I had to delete the coffeescript version installed by npm and link the old location with the apt-get package: sudo ln -s /usr/bin/coffee /usr/local/bin/coffee – Moritz Mair Nov 5 '13 at 9:58
2

Continuing to the theory added by @Mitja, You can have your script running as follows:

  1. The coffescript folder has a js file where #!/usr/bin/env node is written means node command will be executed as found available inside /usr/bin folder but if we check using which node command then it shows a different path means there is already a node command available in our Ubuntu system. And nodejs ( not legacy ) also includes the node command so let's move on to Step 2 and create a new command nodejs

  2. sudo ln -sf Path/to/NodeJs/extracted/folder/nodejs4.4.7/bin/node /usr/bin/nodejs
    This command will create a soft link named nodejs command in /usr/bin folder and we would name it as nodejs ( or any other) for our ease. I never wanted to stay with apt-get install to work with old nodejs so used the downloaded the latest stable code instead.

  3. Now run which nodejs command and you would see /usr/bin/nodejs which automatically gets available under the environment path.

  4. Return back to your coffeescript js file and change the command from node to nodejs i.e. #!/usr/bin/env nodejs

Save and tada..

Run your coffeescript with your actual hot coffee

1

According to this coffeescript issue from 2010, a name conflict leads to the issue that the node ubuntu packet (not to be confused with the nodejs packet) takes the name node for itself, whereas Node.js only gets the nodejs command name.

Entering coffee calls node and the expected node would be the executeable from Node.js, but it gets the wrong executeable. A workaround for this is removing the node packet from the system via the packet manager and symlinking node to nodejs:

ln -s /usr/bin/nodejs /usr/local/bin/node
ln -s /usr/bin/nodejs /usr/local/sbin/node

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.