Installation of Nodejs and NPM under Windows, common commands, NODEJS development environment configuration

Source: Internet
Author: User
Tags sublime text git commands

First step: Download Nodejs and install

Official: https://nodejs.org/en/, I chose the long-term support version v4.47, installation as long as the next step is OK

After the installation is complete, you can use CMD (win+r and then enter CMD entry) to test if the installation is successful. Method: Enter node-vunder CMD, the version prompt is complete the installation of Nodejs.

We open the installation directory:

Discover the Nodejs directory there is a node.exe, what is it for?

Step Two: NPM installation

Before v0.63, in the node installation process, the actual need to install NPM, to v0.63 when Ndejs has integrated NPM, so you do not have to consider NPM installation problems. You can also use the cmd command line to enter "Npm-v" to test for successful installation

Step three: Run the test sample

Create a cs.js file with the editor and place it in the installation directory (not required)

The sample code is as follows:

1 var str= "Hello"; 2 console.log (str);

On the cmd command line, enter the command as follows:

Run Result: Hello

Note: Enter node in the cmd command line, enter node development mode, exit as?

Fourth step: Create New Node_cache, Node_global, and set environment variables

    • In the root directory of node installation, which is the Nodejs folder, create a new two folder named Node_cache, Node_global
    • Set Environment variables:
      Variable name: Node_path
      Value: C:\Program files\nodejs\node_global\node_modules
      Note: Because I am installing Nodejs in the C:\Program files\ directory, the environment variable is set accordingly;

Common Command Introduction

NPM Help View assistance

NODE-V View node version

Npm-v View NPM version

NPM Install <module name> installation components and modules

NPM Install <module name>-G in the Global Environment installation module

NPM Uninstall <moudle name> unload module

NPM LS Displays the modules installed in the current directory

NPM View moudlename dependencies viewing package dependencies

NPM view Modulenames Viewing the Package.json folder of the node module

NPM View ModuleName labelname View the contents of a tag under the Package.json folder

NPM View ModuleName Repository.url Viewing the source file address of a package
NPM View ModuleName Engines View the version of node that the package depends on
NPM Help Folders view all the folders used by NPM
NPM rebuild ModuleName used to change package content after rebuilding
NPM outdated check if the package is obsolete, this command lists all the obsolete packages that can be updated in a timely manner
NPM update ModuleName Updating the node module

Sublime Text3 node. JS Development Environment Configuration

First step: Download plugin Sublimetext-nodejs

    • Download compression packs directly on GitHub

Address: Https://github.com/tanepiper/SublimeText-Nodejs

Download the package directly and extract it to the sublime text directory and rename it to Nodejs. See where the package directory can be accessed directly from the preferences--> browse packages in the menu bar.

    • Git methods

Use git commands to download to the package directory (such as Git clone Https://github.com/tanepiper/SublimeText-Nodejs "E:\ProgramFiles\Sublime Text 3\data \packages\nodejs ")

Step two: Modify the corresponding values

To modify the compilation options, in the Nodejs directory under the package directory, open the Nodejs.sublime-build

有2个地方需要修改,一个是编码,为了避免乱码,将代码 "encoding": "cp1252" 改为 "encoding": "utf8" ;另外一个是cmd命令,本身如果只是想简单的运行nodejs程序的话,windows下面的cmd可以直接 "cmd": ["node", "$file"]

Open the file "nodejs.sublime-settings" and change the code "Node_command": false to "Node_command": "C:\\Program Files\\nodejs\\ Node.exe " , change the code " Npm_command ": false to " Npm_command ":" C:\\Program Files\\nodejs\\npm.cmd " , Save File

After restarting sublime text, the configuration is complete. Let's write a short piece of code to verify that it works.

1 varHTTP = require (' http ');2 3 varOS = require (' OS ');4 5Http.createserver (function(Request, response) {6 7Response.writehead, {' Content-type ': ' Text/plain '});8 9Response.End (' Hello world\n '); }). Listen (3000);Ten  OneConsole.log (' Server running at Http://127.0.0.1:3000/');

Ctrl+b The code is compiled, the Sublime text window will display

Server running at Http://127.0.0.1:3000/

If a previously running node process is in progress, the node process will be killed first, and then node can be started, as shown below:

Success: The process "Node.exe" has been terminated with a PID of 154588.

Server running at Http://127.0.0.1:3000/

In this case, the server is started successfully, open the browser, enter Http://127.0.0.1:3000/, the page shows Hello World is normal interaction.

(My Nodejs is installed in C:/Program Files/nodejs)

Installation of Nodejs and NPM under Windows, common commands, NODEJS development environment configuration

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.