ubuntu14.04安装最新node.js
1、安装最新的nodejs和npm
复制代码代码示例:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get update
sudo apt-get install nodejs
2、检测版本
node --version
npm -v
npm -v
3、升级npm
sudo npm install -g npm
nodejs can not install by : apt-get install nodejs, the nodejs is other application.
在服务器端使用less
安装
在服务器端安装 LESS 的最简单方式就是通过 npm(node 的包管理器), 像这样:
$ npm install less
如果你想下载最新稳定版本的 LESS,可以尝试像下面这样操作:
$ npm install less@latest
使用
只要安装了 LESS,就可以在Node中像这样调用编译器:
var less = require('less');
less.render('.class { width: 1 + 1 }', function (e, css) {
console.log(css);
});
上面会输出
.class {
width: 2;
}
你也可以手动调用解析器和编译器:
var parser = new(less.Parser);
parser.parse('.class { width: 1 + 1 }', function (err, tree) {
if (err) { return console.error(err) }
console.log(tree.toCSS());
});