login community faq
0
1

I am trying to install a css less compiler, lessc. I have found a wiki online that explains how to do just that on a debian server. I have followed the instructions (with a few tweaks to get all the steps to work) and I get this message:

1
2
[xxxxxx@webXXX ~]$ lessc
/usr/bin/env: node: No such file or directory

What I understand from that is that the lessc command is working but it depends on the node command to work and it's not available.

Ultimately, I'd like to understand (1) the process of installing external packages, (2) where to put them, (3) where to find them, (4) how to remove them from your environment, all that, within the context of webfaction. This link here answers alot of those questions, but some pieces are missing.

Anyone who has had experience installing css compilers (less, sass) and node could give me a hand?

asked Sep 19 '12 at 17:18

mjlavoie's gravatar image

mjlavoie
11


Overview

The 'lessc' program is actually a javascript file which is run via node, so you'll first need to install node using this related community post, or manually using our home-install guide.

Then, once that's done, grab Less CSS.

The installation procedure for lessc is similar to the home-install guide, except that it seems that less CSS doesn't use the "./configure" step. After installing node, you should be able to just run "make" or use bin/lessc directly.

Guide

Install node.js and then lessc.

Recently node is much easier to install than in the past, so we can just install it as any other normal source-code application:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# create ~/src, where we keep all source code
mkdir -p $HOME/src

###########################################################
# node 0.8.9
###########################################################
cd $HOME/src
wget 'http://nodejs.org/dist/v0.8.9/node-v0.8.9.tar.gz'
tar -xzf node-v0.8.9.tar.gz
cd node-v0.8.9
./configure --prefix=$HOME
make                         # build it
make install                 # install it

# clear the shell hash so we know we're using the correct path
hash -r
which node    # should be ~/bin/node

###########################################################
# Less CSS
###########################################################
cd $HOME/src
git clone 'https://github.com/cloudhead/less.js.git'
cd less.js
make                         # build it
cp -r ./bin/* $HOME/bin/     # install binaries
cp -r ./lib/* $HOME/lib/     # install libraries

# clear the shell hash so we know we're using the correct path
hash -r
which lessc        # should be ~/bin/lessc

Discussion

Installing software has three parts. First, you configure it, which means changing and setting the compile-time options. Many pieces of software can be compiled in different ways, with different internal paths, and with certain options like multithreading turned on or off. The ./configure stage does this, and when installing node, we used ./configure --prefix=$HOME. Setting the --prefix is setting a compile-time option which defines the internal paths hard-coded into the binary itself. Running the ./configure step generates a Makefile.

Some programs are so simple that don't have any compile-time options at all, or they have just a handful which can be manually set inside of the Makefile itself. These programs don't have a ./configure step. You can recognize them because they don't have a configure script inside of the source directory, but directly have a Makefile instead. lessc was one such example.

The next step is to compile the software. This is what the make command does. When you type make, it compiles the software, putting all of the compiled programs into subdirectories of your current working directory. The make command uses the Makefile as its recipe for how to do this.

The final step is to install the software. Installation usually means nothing more than copy-pasting those binaries into their new permanent locations. In the first example here where we installed node, the make install step knows about the --prefix we set during the configure stage, so just typing make install copies the compiled files to where they can be run. In our case, that puts node inside of $HOME/bin. But you should also be aware that it put a library inside of your $HOME/lib directory too.

The lessc program didn't have any such make install mode. You can try typing make install to see if it works - it doesn't, in this case, so we just do a manual install by copying the binaries and libraries to $HOME/bin and $HOME/lib respectively. To "uninstall" a program, delete the files you installed.

There is a lot more to installation than this. For example, sometimes some software needs to compile in dependencies for other software, which is where the CPPFLAGS, LDFLAGS come into play. And sometimes programs need to have your $HOME/lib on the library path in order to function when you try to execute them -- and that's what LD_LIBRARY_PATH is for. These environment variables are covered briefly in our documentation.

If you're looking for in-depth knowledge and examples about compiling and installing software on linux, the book How Linux Works by Brian Ward is the best material on the subject that I've seen, so I'd strongly recommend it as the best place to start to really understand what's going on.

Hope that helps!

answered Sep 19 '12 at 20:32

ryans's gravatar image

ryans ♦♦
28411420

edited Jan 14 at 22:25

You sir are a gentleman! I really appreciate the (very complete) answer you took the time to write.

In the set of instructions provided, "which node", instead of the expected results outputs as follows:

[xxxxxxxx@xxxxxx node-v0.8.9]$ which node /usr/bin/which: no node in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/dell/srvadmin/bin:/home/xxxxxxxx/bin)

Ok, it's not there. Well perhaps creating a soft link to out/Release/node in ~/bin/ would work since installing is sometimes a matter of copying bin and lib in the right folders, so I did:

[xxxxxxxx@xxxxxx node-v0.8.9]$ ln -s out/Release/node ../../bin/node [xxxxxxxx@xxxxxx node-v0.8.9]$ ll ../../bin/

Listing the contents of bin prints out "node -> out/Release/node" all in red. Trying "which node" gives the same results as before. I am stumped.

(Sep 20 '12 at 20:14) mjlavoie mjlavoie's gravatar image

It is difficult to see why it is failing from here. It is likely related to the paths, and we could investigate more with a support ticket.

(Sep 20 '12 at 23:45) johns ♦♦ johns's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×21
×5
×3
×2
×1

Asked: Sep 19 '12 at 17:18

Seen: 1,987 times

Last updated: Jan 14 at 22:25

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited