sudo apt-get update && apt-get upgrade
sudo apt-get install nodejs
sudo apt-get install npm
##Version
# nodejs -v
v0.10.25
Still 0.xx, really??
##Hello world
# more hw.js
#!/usr/bin/env nodejs
console.log('hellow world');
##Run
# ./hw.js
hellow world
##Install a package - JQuery
Use package manager npm
# npm list
/root
└── (empty)
# npm install jquery
npm http GET https://registry.npmjs.org/jquery
npm http 200 https://registry.npmjs.org/jquery
npm http GET https://registry.npmjs.org/jquery/-/jquery-2.1.4.tgz
npm http 200 https://registry.npmjs.org/jquery/-/jquery-2.1.4.tgz
jquery@2.1.4 node_modules/jquery
# npm list
/root
└── jquery@2.1.4
Looks OK.
# ls
hw.js node_modules tmp
node_modules and tmp showed up after npm install
In order to use JQuery in node, you need jsdom 3.1.2. The latest jsdom does not work with node js anymore.
npm install -S 'jsdom@3.1.2'