How to install Node.JS

“Isn’t it just simply googling ‘how to install Node'” you asked? Yes it isn’t.

  • The default Node installer will require administrator privilege
  • The node process will require admin privilege also if installed that way (which is a bad idea: every time you need to update node you must sudo)
  • You can’t easily switch node version if you work with multiple projects

Introducing nvm (node version manager), a script that installs node in your local user directory, requiring no sudo while compromising none of the quality

How to use it? According to Zoltan:

On Mac

The best way to install Node.js on Mac is nvm.

https://github.com/creationix/nvm

You have to have on your Mac the Command Line Tools. Or you install the full XCode from App Store either just use the small Command Line Tools installer:

$ xcode-select --install

(If you’ve just installed XCode, don’t forget to launch it first and accepting the Terms and Conditions.)

You can use the install script for nvm installation.

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

However, I would encourage you to use the manual installation process. Nothing special there. Firstly, you just clone the whole repo in a subfolder in your home directory. (~/.nvm) Secondly, you add two extra lines to your console script.

Please follow these steps on NVM Readme: https://github.com/creationix/nvm#git-install

You have to relaunch your Terminals. Maybe you have to log out and log back to activate the new settings.

List your installed node versions:

$ nvm list

List the available node versions in the cloud:

$ nvm ls-remote

You can use the combination of this two commands to see only the last 9 lines from the huge list of versions: $ nvm ls-remote | tail -n9

It is safe if you choose one of the most recent LTS (long time support) version and install it with the following command:

$ nvm install 10.3.0

Setup this version as the default.

$ nvm use 10.3.0
$ nvm alias default 10.3.0

Check your node version with

$ node -v

You should see v10.3.0 if you installed the above version.

You can update your npm to the latest.

$ npm install -g npm

After the update, the npm version, npm -v, should be at least 6.1.0 or above.

A little extra tip. Remember for the following command because it simplifies the update process. 😉

Let’s say, you would like to stay on the stable, LTS version and you would like to keep all the global package what you’ve already installed. Here is the solution:

$ nvm install 8 --reinstall-packages-from=8 --latest-npm

It updates your Node.js version to the latest version 8 and install the latest npm, plus it setup all your previously installed global packages.

Alternatives for installing Node.js, but not suggested:

On Linux

Please avoid to install Node.js with apt-get on Ubuntu. If you already installed Node.js with the built in package manager, please remove that. (sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean)

The installation process on Linux is the same as on OSX.

With the provided script:

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

(Please read the instructions under OSX section.)

$ nvm list
$ nvm ls-remote
$ nvm install 10.3.0
$ nvm use 10.3.0
$ nvm alias default 10.3.0
$ node -v
$ npm install -g npm
$ npm -v

One more thing! Don’t forget to run the following command, which increases the amount of inotify watches.

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

On Windows

On Windows, if you don’t need more version from Node.js, you can use the official installer.

Install also Git for Windows.

Additionally, don’t forget to read this instruction, which is very interesting not just for Ember developers, but for everybody who uses Node.js on Windows.

Plus install and run ember-cli-windows

$ npm install -g ember-cli-windows
$ ember-cli-windows

More here: https://github.com/felixrieseberg/ember-cli-windows

Always run your PowerShell or CMD.exe as Administrator.

Don’t forget to run these two commands in PowerShell (as Administrator):

$ Set-ExecutionPolicy Unrestricted -scope Process
$ ember-cli-windows

Log out and log back in Windows.

Try to upgrade npm and after install the latest ember-cli

$ npm install -g npm
$ npm install -g ember-cli

I would suggest, experiment with different shells. Which worked better for you? PowerShell, Git Shell, the original CMD.exe? Please, share your Windows experiment in a comment.

Location service emulation on popular platforms

This post in a nutshell: How to run GPS emulation with several mobile platform and a short evaluation of each.

Windows Mobile

On Windows Mobile 5, you get a “GPS” settings applet but there is no GPS emulation tool. The attached documentation (GPS sample) state that you’ll need a real GPS device for the sample to work (and remember to configure it for develapment!); then I downleaded a new version hoping for better support. The first thing I noticed touching the WM6 SDK is the vast amount of tools added: Cellular network emulator, package tools, test framework, and of course among them: a GPS emulator. Looks like Microsoft has finally started to fear Sun.

The GPS emulator is in WM6 SDK folderGPS. Access the CAB file from your device to install it. Additionally, the settings.exe can only be run inside the device and is the same things as the GPS applet. The documentation is still vague, but the tool works.

Here’s the interesting bit: The WM6 FakeGPS work perfectly well on WM5, so you don’t need the new (and huge) SDK to work on location services, just copy the FakeGPS from someone who installed (it’s around 1MB)

020509-1131-locationser1.jpg

The data file structure is pretty clueless, but I may eventually figure that out after some more searching :/

$GPGLL,36000.0000,N,72000.0000,E,000023.998,V*1A
$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
$GPRMC,000023.998,V,36000.0000,N,72000.0000,E,0.000000,,101102,,*30
$GPGGA,000024.998,0000.0000,N,00000.0000,E,0,00,50.0,0.0,M,0.0,M,0.0,0000*78
$GPGLL,36000.0000,N,72000.0000,E,000024.998,V*1D

What left to be wondered is, why GPS is taken out of Smartphone and available only for PocketPC? While it’s true that a phone ‘s functionalities are not as easily extended with cards and stuff like a PDA but some of them can locate themselves; or Microsoft thinks 3G should not include location services? Oh well…

Symbian

Given the previous experiences with Symbian, I expected this platform to be the hardest to configure. Looks like I worried too much :). You can select the emulated location service from the phone’s settings. Just go to settings / general / positioning and select simulation, choose settings on this mode to choose emulation data.

Symbian’s emulator can read 2 types of data: the one Windows Mobile used above (nmea.nme is included with the demo) and .sps files. Sps files seem to define non-deterministic movement, like this:

Horizontal accuracy=10;
Vertical accuracy=16;
TimeToFix min=2;
TimeToFix max=7;
Powerup time=5;
Longitude=23.9385;
Latitude=61.5285;
Speed=0;
Course=113.9;
Deterministic=0;

Getting the sample application running is pretty easy too. They even have 4 more examples for this topic and each comes with detailed information on how the classes work.

020509-1131-locationser2.jpg

J2ME

The most straightforward platform! The Location service example is there (called CityGuide), Location and landmark service is built-in with the emulator. To simulate movement, from the emulator choose MIDlet/External events, toward the bottom you’ll see the “Location” group, click Browse to select the path file (City guide comes ready with a path file, citywalk.xml), press play and you are on the move!

The data file is different from both of the above platforms, which belongs to some kind of standard, which is good but to me J2ME’s xml is the best! It’s the cleanest and most human-readable data. Ph34r the power of XML!

<waypoint time="6500" latitude="14.394759972655674" longitude="50.10266737954043" altitude="310" />
<waypoint time="1500" latitude="14.395190022566581" longitude="50.102641304996304" altitude="310" />
<waypoint time="1500" latitude="14.395487422916618" longitude="50.10265163602227" altitude="310" />
<waypoint time="1500" latitude="14.395935213738783" longitude="50.10265925148049" altitude="310" />

020509-1131-locationser3.jpg

I think the landmark tool is build for some purpose, but clearly the sample work well without any tweaking by this tool.