A
A
Alexander2016-02-24 13:24:38
MongoDB
Alexander, 2016-02-24 13:24:38

How to properly install NodeJS on Ubuntu 14.04.03 LTS server?

Instead of an epigraph:
This note is a cheat sheet on the competent installation of NodeJS on the server for people who, like me, practically understand nothing not only in programming, but also in Linux as such. But we will try to reduce your communication with Linux to literally poking one single button, at least until you get comfortable.
It is compiled using answers not only from the Toaster community, but also from the Linux community as a whole, Google and personal practice.
In particular, they helped me: lem_prod , Anton Ulanov , inf (the list will be expanded as we work on the cheat sheet)
The current version of the cheat sheet: (v. 0.0.9)

As a person just starting to learn nodejs and rather superficially familiar with Linux, I, in particular, did not find ANY mention of how to install NodeJS step by step and easily on an Ubuntu 14.04.03 LTS server.
A short list of issues I've encountered and some of which I'm currently digging around like crazy:
Q: Is it possible to create a project folder in a separate folder in Linux?
O: Yes. In general, as I understand it - even desirable.
Q: Is it necessary (if there is a python 2.7 in the system, for example) to set for the node apt-get install python-software-properties ?
A: No, if you use the current cheat sheet.
Q: Do I need to do it apt-get install npmif it is considered to be ALREADY included in Nodejs?
O:No, this cheat sheet gives you the fifth version of Noda, which already includes npm.
Q: Why, when I try to install apt-get install express, does the system tell me what it needs apt-get install node-expressand is it the same as expressjs?
A : Q
: What SPECIFIC folders does the node itself and its modules fall into? Is it necessary for them to define a specific installation path relative to the place that is prepared for the project (it is obvious that it is not worth doing the project in the folder with the node itself, here we will omit at least part of the CEP)?
A :
Q: Is it necessary in EVERY folder (for example, if there is a folder in the myapp folder, a folder for a separate chat is created), being in it to speak the console npm install --save ?
O:
These, and a huge number of other questions arise before beginners. Yes, most will ask even more questions. For example -

"Why do you need to deploy the project immediately on a server in the network? Isn't it easier to do everything on your computer?"

Let's take this out of the scope of my question. Because, firstly - no, it's not easier for me. Secondly - let's assume that this (for example) is some elective. Thirdly, in Node, the NODE_ENV directives with production and development parameters are described in order to make this all possible, right? And although there are a lot of examples of working with Noda in the locale and on servers, there are critically few specifics of a technical sense in them.
I ask the community, if possible, to answer my (perhaps funny or naive in some ways) questions, from which I could compile a guide for such an elective on the correct deployment of node.js on a production server for beginners, especially since I have such examples not found anywhere on the net. So why not put together another one with an unexpected approach to setting up this wonderful server?
project parameters:
- WDS server from %%known_hosting_name%%, we can do without advertising
- single-core processor, with a frequency of 1GHz
- 512 RAM
- 10GB of space.
For starters, that's it.
But let's start, perhaps:
0/ useradd vasya// Let's agree with you that we perform all further operations on behalf of a simple user Vasya Pupkin, which we will create on behalf of the root.
1/ sudo apt-get update // This will update the update source lists for the server.
2/ sudo apt-get ugrade // Let's update the server!
3/ sudo apt-get install htop// Very handy to see processes, memory consumption and so on. we write in the console htopand use it.
4/ sudo apt-get install mc//A very handy file. We want to use - we write in the console mc .
5/
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -

// Install NodeJS version 5.x
6/ apt-get install -y nodejs --save
//npm IS INCLUDED IN THE PACKAGE WITH NODE , you don't need to install it separately now.
7/ npm install -g supervisor --save // Install the module that tracks changes in the files and folders of your project.
8/ npm install -g forever --save// Install a module that allows you to create/(re)launch the main file (for example, the same app.js)
9/ npm install -g express-generator --save// Install a template engine that expands the project with primary folders.
10/
11/ Flags: * --save

: writes the module to be installed to the package.json file, which stores the description of the project and its dependencies (a really useful thing) The command flag has two features, this is not a typo.
** -g : Installs globally for the entire operating system.
*** -y >: is an abbreviation for the "yes" flag.
...to be continued. Want to help? Join now! ;))

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lem_prod, 2016-02-24
@w4r_dr1v3r

- is it possible to create a project folder in a separate folder in linux?
of course the node variable is global
- is it necessary (if there is a python 2.7 in the system, for example) to install apt-get install python-software-properties for the node
don't know, but why?
- do I need to install apt-get install npm if it is considered to be ALREADY included in nodejs
No
- why, when I try to install apt-get install express, the system tells me that it needs apt-get install node-express and is it the same as expressjs
express is installed via npm: sudo npm install -g express
- what SPECIFIC folders does the node itself and its modules fall into? Is it necessary for them to determine a specific installation path relative to the place that is prepared for the project (it is obvious that it is not worth doing the project in the folder with the node itself, here we will omit at least part of the CEP)
I don’t remember, now I’m sitting under Windows, I won’t say, but in fact it doesn’t matter, look at the first releases of Kantor’s screencast on the node, he explains well how modules are searched and how to organize the structure

A
Anton Ulanov, 2016-02-24
@antonsr98

I put it quite simply

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

then installed express-generator via npm i -g express-generator (-g is a global install)
project directories are created via express wherever you want.
about npm install module_name --save this command writes the module to be installed to the package.json file, which stores the description of the project and its dependencies (a useful thing)

I
Ilya Erokhin, 2016-02-25
@AirWorker

I currently prefer to score on apt and install from raw. The inertia of Noda and Debian is generally a different level of things.

$ cd /usr/local/src
$ wget http://nodejs.org/dist/v5.7.0/node-v5.7.0.tar.gz # <= latest version here
$ tar -xvzf node-v5.7.0.tar.gz
$ cd node-v5.7.0
$ ./configure
$ make
$ sudo make install
$ which node
$ node -v

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question