NODEJS development environment Configuration and use _node.js

Source: Internet
Author: User

First of all, Nodejs this oh, some people think it is a language, in fact, it is a platform, a Google V8 engine on the platform for the JS, is to parse JS, and provide their own API to the user to call. From the present point of view, this development is good, tomorrow there are a lot of front-end engineers in the join, even some great God also pay attention to even write a blog, last night I saw an article wrote a foreign website wrote nearly 90 Nodejs Web plug-ins, this really cow ah! That learning Chinese east for us the most direct can bring what benefits it: Front-End personnel due to familiar with JS can be basically easy to learn Linux can start, then the backstage engineer is a little trouble, because some background engineer is not how familiar with JS use may be a lot of obstacles, here suggest learning Learning the basics of JS, after talking about this, I think it is the salary of the problem, to the present, the basic in more than 1 years of Nodejs engineers in Guangzhou already have an offer in more than 7K, this is also a former colleague said his company recruitment situation I just know that this stuff is pushing Hadoop! This is the next topic: The Environment configuration (because I was developed under Windows 8.1, so here only to talk about Windows).

Install Nodejs

First go to nodejs official website http://www.nodejs.org/download/Download the corresponding version, mine is 64-bit. After the download is installed directly, because the current version has been to v0.10.33, so node and NPM have been installed together, even the environment variables are set up, installed in the corresponding folder can see the following

After installation, you can use the current installation of the folder under the SHIFT + right to open cmd, enter the following to view the installed version, I am 0.10.32.

Node-v

Second, global folder settings

As for the Node_cache and Node_global for beginners This should not be set, because he will be set to the current user directory, but sometimes his own for convenience also will be set, here is provided under the command to set the following look:

npmconfigls//List prefix configuration
Npmconfigsetcache ' D:\ProgramFiles\nodejs\node_cache '//Set global cache folder
Npmconfigsetcache ' Node_global '//Set Global module folder

Third, the installation module

Now that we've installed node and NPM, NPM is the name of node's package Manager, managed by command, now try:

Let's install a Web frame Express, the parameter-G is installed in the Global folder, and if not, the current folder is represented

Npminstallexpress-g//express can also bring the @ version number

We are now in the folder just set up to see if there are more files Ah, here we use the command to see just installed the Express version number

Express-v

If an output version represents a successful installation!

So if we want to uninstall this plugin, we can use the following command

Npmuninstallexpress

So we install back the express after unloading, but with the version number 3.2.2 (because I am familiar with the version is this), this will be?

Four, use Express installation

Now we use the command to build a Web site, as follows:

Expresstest

This will output some hints, you can jump directly in the test folder to run this site using the command:

Nodeapp.js

See the hint, Port 3000 indicates that the launch was successful, but our browser to browse the error, hint what

error:cannot Find module ' Jade '

That unexpectedly has prompted the error, then we will install this module now, in this note, this folder has a Package.json file, this file describes some site information, we can use Nodepad open look:

This makes it clear that need 2 libraries, one is express, so that one is jade, then we now to install it, if many module installation is not to perform many commands, here is a simple command, it will check the current Package.json dependent library for installation:

Npminstall

Install this module we also need to modify the views of the Layout.jade file in the first line of the DOCTYPE 5 to DOCTYPE HTML. So we can rerun node app.js our site will function properly.

V. Installation of Supervisor Plug-ins

Just now we may have found that if there is a problem, Nodejs automatically stopped the service, so it is not conducive to debugging ah, then we have a plug-in can be resolved. This plugin is the process of managing Nodejs, including debugging which are very useful. Install the global module using the following command:

Npminstallsupervisor-g

This allows us to use the node command to start the service, directly using Supervisor App.js.

Vi. using the Webstorm IDE

Just now we edit JS file is to use Nodepad to come, but this is not very good, there is a good editor, the answer is some, a big name top of the Webstorm, online a lot of that version of the download, we know, here also provides a link to the user http://yunpan.cn/ CACF6HVXNIBCT extraction Code 246f, download the direct installation, install the cover of an EXE file on it, cock silk so simple!

The first run will open a folder, which is actually the folder for the project.

The following debugging issues, including I also engaged in a long time on the internet also looked for a long time, and finally in Pogo would said just to fix, this is actually difficult to simply, directly to see the picture:

How to interrupt the point in the program can be debugged, very convenient.

The above is the individual for NODEJS development environment configuration and use of all the experience of the record, follow-up and continue to share some Nodejs detailed application.

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.