Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install lessc and nodejs in a Python virtualenv?

I would like to install a nodejs script (lessc) into a virtualenv.

How can I do that ?

Thanks

Natim

like image 410
Natim Avatar asked Jan 24 '12 12:01

Natim


People also ask

Does Nodejs have virtual environment?

nodeenv (node. js virtual environment) is a tool to create isolated node. js environments. It creates an environment that has its own installation directories, that doesn't share libraries with other node.

How do I get multiple node versions?

Installing Node Version Manager Node Version Manager alias NVM is Node Module which helps to maintain multiple node versions in a same machine to manage various versions. `nvm` and `n` Node Module does not support windows. use below module.

What is a virtual environment in Python?

A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them. This is one of the most important tools that most of the Python developers use.


2 Answers

I like shorrty's answer, he recommended using nodeenv, see: is there an virtual environment for node.js?

I followed this guide: http://calvinx.com/2013/07/11/python-virtualenv-with-node-environment-via-nodeenv/

All I had to do myself was:

. ../bin/activate # switch to my Python virtualenv first
pip install nodeenv # then install nodeenv (nodeenv==0.7.1 was installed)
nodeenv --python-virtualenv # Use current python virtualenv
npm install -g less # install lessc in the virtualenv
like image 196
Andre Miras Avatar answered Oct 15 '22 15:10

Andre Miras


Here is what I used so far, but it may be optimized I think.

Install nodejs

wget http://nodejs.org/dist/v0.6.8/node-v0.6.8.tar.gz
tar zxf node-v0.6.8.tar.gz
cd node-v0.6.8/
./configure --prefix=/absolute/path/to/the/virtualenv/
make
make install

Install npm (Node Package Manager)

/absolute/path/to/the/virtualenv/bin/activate
curl https://npmjs.org/install.sh | sh

Install lesscss

npm install less -g

When you activate your virtualenv you can use lessc

like image 36
Natim Avatar answered Oct 15 '22 14:10

Natim