Processing
 

Launch Nodejs/Angularjs app in Ubuntu

12/12/2014 14:32#1

Joined at: 7 months ago

Post: 1

Thank: 0

Thanked: 0

I have just read tutorial on Angularjs and wanted to run test application (by (C) Wahlin Consulting) from http://tinyurl.com/AngularJSDemos . Its readme informs that:

NODE.JS OPTION:  If you want to run the site using Node.js (install it from http://nodejs.org) run the following at the command-prompt from within the AngularJSDemos folder:  node server.js  Now navigate to http://localhost:8080/DemoList.html or     http://localhost:8080/CustomerManagementApp in your browser. 

I have installed nodejs and tried to launch it from terminal in my Ubuntu system:

mainuser@mylaptop:~$ cd /home/mainuser/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos/ mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js The program 'node' can be found in the following packages:  * node  * nodejs-legacy Try: sudo apt-get install <selected package> mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ sudo apt-get install node  ...  mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js & [1] 11153 mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js [1]+  Exit 1                  node ./server.js mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ sudo apt-get install nodejs Reading package lists... Done Building dependency tree        Reading state information... Done nodejs is already the newest version. The following packages were automatically installed and are no longer required:   kde-l10n-engb kde-l10n-pl linux-headers-3.13.0-32   linux-headers-3.13.0-32-generic Use 'apt-get autoremove' to remove them. 0 to upgrade, 0 to newly install, 0 to remove and 28 not to upgrade. mainuser@mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$  

But whatever I do, I cannot launch this example. In Chrome "This web page is not available" and in Firefox "Unable to connect". Moreover, it looks like I simply cannot launch it in terminal.

How to launch this example?

12/12/2014 14:38Top#2

ladislas

Member

Joined at: 9 months ago

Post: 3

Thank: 0

Thanked: 0

I'd recommend using nvm to install node and manage different version on your system.

It's quite easy:

# First, we need to clone the nvm repository: $ git clone https://github.com/creationix/nvm.git ~/.nvm  # Then, we need to add the following line to our .profile, .bashrc or .zshrc: $ echo "source ~/.nvm/nvm.sh" >> .zshrc 

Installing nvm is not enough, we now need to install node & npm.

# To print out the list of all the available versions, simply run: $ nvm ls-remote  # We want to install the current stable version which is v0.10.26, so we need to run: The -s flag means we want to compile node from source. $ nvm install -s v0.10.30 

When the installation process is finished, our brand new node and npm will be installed! The great thing with nvm is that you can use a different version of node in each of your shell instances. But if you want to stick to the latest version, you can set it as default by running:

$ nvm alias default 0.10.30 

Make sure everything is up and running by typing node -v && npm -v

09/05/2015 09:26Top#3

svarog

Member

Joined at: 11 months ago

Post: 10

Thank: 0

Thanked: 0

Here's a different approach for this problem, the tutorial is suggesting using npm and it's fine. but it takes time, an internet connection and setting up. Here's an alternative way, if you're already using Ubuntu, python should already be installed in your system. your python installation already comes with a simple HTTP server you can use to run your angular application.

in your console, type python -m SimpleHTTPServer 8080

then direct your browser to localhost:8080

and locate your angular project. then it should run properly.

09/05/2015 09:36Top#4

Joined at: 11 months ago

Post: 2

Thank: 0

Thanked: 0

You probably installed incorrect node package.

Thanks to that your node command is not equal to nodejs but invokes something totally different.

Try with

nodejs ./server.js 
04/07/2016 05:38Top#5

Amayra

Member

Joined at: 11 months ago

Post: 2

Thank: 0

Thanked: 0

Install node in ubuntu using

sudo-apt-get install nodejs sudo apt-get install npm sudo apt-get install build-essential 

and then run your server with following command

npm start 
Similar articles

Non-interactive method for dpkg-reconfigure tzdata

5 years ago - Reply: 3 - Views: 142

monit is not able to read mongod.lock

2 years ago - Reply: 3 - Views: 139

Ubuntu: hadoop command not found

2 years ago - Reply: 4 - Views: 244

C# Mono Console.ReadLine quitting

4 years ago - Reply: 1 - Views: 87

linking jsoncpp on Ubuntu

2 years ago - Reply: 1 - Views: 6

Build artifacts over ssh jenkins - PHP

2 years ago - Reply: 1 - Views: 38

Can't load Metasploit after installation

3 years ago - Reply: 5 - Views: 222

Selenium FirefoxDriver in Headless get error

2 years ago - Reply: 1 - Views: 96

Unable to start MongoDB. ERROR: addr already in use

2 years ago - Reply: 2 - Views: 120

ZSH Agnoster Theme showing machine name

2 years ago - Reply: 4 - Views: 248

Unable to start firefox browser with jenkins user

2 years ago - Reply: 2 - Views: 111

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re