Step 1: Get the source code with Curl
Before we get the source code with curl, we must first upgrade the operating system and then use the Curl command to get Nodesource added to the local repository.
[Email protected]:~ #apt-get Update
Install Apt-get installed curl and apt-get install sudo
[Email protected]:~# curl-sl Https://deb.nodesource.com/setup | sudo bash-
Step 2: Install Nodejs and NPM
After running the above command, if the output is as shown above, we can use the Apt-get command to install the Nodejs NPM package.
[Email protected]:~# apt-get Install Nodejs
Nodejs Installation
Nodejs Installation
Step 3: Install some of the necessary tools
Install some of our required local plugins by installing compile and install the following command.
[Email protected]:~# apt-get install-y build-essential
Test with the node. JS Shell
The steps to test node. JS are similar to the previous use of source code installation, and the following node commands confirm that node. JS is fully installed:
[Email protected]:~# node
> Console.log (' node. js installed Using package Manager ');
node. JS Installed Using Package Manager
[Email protected]:~# node
> A = [1,2,3,4,5]
[1, 2, 3, 4, 5]
> typeof A
' Object '
> 5 + 2
7
>
(^c again to quit)
>
[Email protected]:~#
Simple testing using the Nodejs application
REPL is a node. js shell, and any valid JavaScript code can run through REPL. So let's see what the REPL is like in node. js.
[Email protected]:~# node
> var repl = require ("Repl");
Undefined
> Repl.start (">");
Press Enter and it'll show out put as this:
> {domain:null,
_events: {},
_maxlisteners:10,
Useglobal:false,
Ignoreundefined:false,
Eval: [Function],
InputStream:
{_connecting:false,
_handle:
{fd:0,
writequeuesize:0,
Owner: [Circular],
OnRead: [Function:onread],
Reading:true},
_readablestate:
{highwatermark:0,
Buffer: [],
length:0,
Pipes:null,
...
...
The following is a list of commands that can be used under REPL
Using the Nodejs Package Manager
The Forbidden City is a command-line tool that provides continuous vitality to the node scripts, which can be package.json to install and manage dependent packages. Start at the beginning of initialization command initialization
[Email protected]:~# NPM Init
Installing node. JS with Package Manager