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?
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
Continuing to the theory added by @Mitja, You can have your script running as follows:
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
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.
which nodejs command and you would see
/usr/bin/nodejs which automatically gets available under the environment path.
Return back to your coffeescript js file and change the command from
node to nodejs i.e.
Save and tada..
Run your coffeescript with your actual hot coffee
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.
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
ln -s /usr/bin/nodejs /usr/local/bin/node ln -s /usr/bin/nodejs /usr/local/sbin/node