Javascript: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 27: Line 27:
Less runs inside Node, in the browser and inside Rhino.  
Less runs inside Node, in the browser and inside Rhino.  


== Installation ==
== Install/update npm - Node Package Manager ==
As you can see from the error message, the node in my Odroid ubuntu 14.04 system is kind of old. Since npm is part of node, we want to update node first. Fortunately [https://nodejs.org/en/download/ node] provides a binary for ARM system too.
 
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
$ npm install -g less
$ npm install -g less
Line 34: Line 36:
npm WARN engine [email protected]: wanted: {"node":">=0.12"} (current: {"node":"v0.10.25","npm":"1.3.10"})
npm WARN engine [email protected]: wanted: {"node":">=0.12"} (current: {"node":"v0.10.25","npm":"1.3.10"})


$ # Install the current version of node/nodejs for my OS (ARM v7). https://nodejs.org/en/download/
$ # Install the current version of node/nodejs for my OS (ARM v7).  
$ wget https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-armv7l.tar.xz | tar xJ
$ wget https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-armv7l.tar.xz | tar xJ
$ PATH=/home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin:$PATH; export PATH
$ PATH=/home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin:$PATH; export PATH
</syntaxhighlight>


== Install Less ==
<syntaxhighlight lang='bash'>
$ # Method 1. Install less via npm. No sudo required
$ # Method 1. Install less via npm. No sudo required
$ npm install -g less
$ npm install -g less
Line 69: Line 74:
-rwxr-xr-x 1 odroid odroid 22261036 May 24 13:30 node
-rwxr-xr-x 1 odroid odroid 22261036 May 24 13:30 node
lrwxrwxrwx 1 odroid odroid      38 May 24 13:30 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 odroid odroid      38 May 24 13:30 npm -> ../lib/node_modules/npm/bin/npm-cli.js
$ lessc -v
lessc 2.7.1 (Less Compiler) [JavaScript]
</syntaxhighlight>
</syntaxhighlight>
As you can see all node.js packages are installed under the node directory. If ''node-v4.4.5-linux-armv7l/bin'' was added to $PATH in .bashrc after we install nodejs, we won't need to include all other binary directories (installed via npm) to $PATH individually.
As you can see all node.js packages are installed under the node directory. If ''node-v4.4.5-linux-armv7l/bin'' was added to $PATH in .bashrc after we install nodejs, we won't need to include all other binary directories (installed via npm) to $PATH individually.

Revision as of 06:51, 12 June 2016

Some resources

Book

Libraries

jQuery UI

It is mentioned in Creating multi-tab reports with R and jQuery UI

npm - node.js package manager

sudo apt-get install npm

Less

Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable.

Less runs inside Node, in the browser and inside Rhino.

Install/update npm - Node Package Manager

As you can see from the error message, the node in my Odroid ubuntu 14.04 system is kind of old. Since npm is part of node, we want to update node first. Fortunately node provides a binary for ARM system too.

$ npm install -g less
npm http GET https://registry.npmjs.org/less
npm http 304 https://registry.npmjs.org/less
npm WARN engine [email protected]: wanted: {"node":">=0.12"} (current: {"node":"v0.10.25","npm":"1.3.10"})

$ # Install the current version of node/nodejs for my OS (ARM v7). 
$ wget https://nodejs.org/dist/v4.4.5/node-v4.4.5-linux-armv7l.tar.xz | tar xJ
$ PATH=/home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin:$PATH; export PATH

Install Less

$ # Method 1. Install less via npm. No sudo required
$ npm install -g less
/home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin/lessc -> /home/odroid/Downloads/node-v4.4.5-linux-armv7l/lib/node_modules/less/bin/lessc
[email protected] /home/odroid/Downloads/node-v4.4.5-linux-armv7l/lib/node_modules/less
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

$ # Method 2. Install less via bow (depending on npm). No sudo required
$ npm install -g bower
/home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin/bower -> /home/odroid/Downloads/node-v4.4.5-linux-armv7l/lib/node_modules/bower/bin/bower
[email protected] /home/odroid/Downloads/node-v4.4.5-linux-armv7l/lib/node_modules/bower
$ which bower
/home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin/bower
$ bower install less
bower not-cached    https://github.com/less/less.git#*
bower resolve       https://github.com/less/less.git#*
bower checkout      less#v2.7.1
bower resolved      https://github.com/less/less.git#2.7.1
bower install       less#2.7.1

$ ls -l /home/odroid/Downloads/node-v4.4.5-linux-armv7l/bin
total 21740
lrwxrwxrwx 1 odroid odroid       35 Jun 12 07:23 bower -> ../lib/node_modules/bower/bin/bower
lrwxrwxrwx 1 odroid odroid       34 Jun 12 07:32 lessc -> ../lib/node_modules/less/bin/lessc
-rwxr-xr-x 1 odroid odroid 22261036 May 24 13:30 node
lrwxrwxrwx 1 odroid odroid       38 May 24 13:30 npm -> ../lib/node_modules/npm/bin/npm-cli.js
$ lessc -v
lessc 2.7.1 (Less Compiler) [JavaScript]

As you can see all node.js packages are installed under the node directory. If node-v4.4.5-linux-armv7l/bin was added to $PATH in .bashrc after we install nodejs, we won't need to include all other binary directories (installed via npm) to $PATH individually.