Installing node. JS with Package Manager

Source: Internet
Author: User
Tags nodesource

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.