NODEJS Development Environment Configuration

Source: Internet
Author: User

This article has been published in my blog.

After several weeks of Nodejs study, from the beginning of the small white to now gradually become familiar with, came to understand, now has also mastered the relevant learning methods, today began to record their own learning process, so that later review.

First say Nodejs This oh, some people think it is a language, actually not, it is a platform, a built on Google's V8 engine JS running platform, is to parse JS, and provide some of their own API to the user call. From the current situation, this development is still good, there are a lot of front-end engineers to join tomorrow, even some great God is also concerned about even blogging, last night I saw an article wrote a foreign site wrote nearly 90 Nodejs Web plugin, this really cow ah! That learning Chinese east for us the most direct can bring what benefit: front-end personnel because of familiar with JS so can basic simple learning Linux can get started, that background engineer is a little trouble point, because some background engineer is not how familiar with JS use up may many obstacles, here suggest learn Learn the basis of JS, said this after everyone concerned about I think it should be the question of salary, to the present, basic in more than 1 years of Nodejs engineers in Guangzhou has already had the offer in the 7K above, this is also a former colleague said his company recruitment situation I just know the original this east to Hadoop Ah! Nonsense first of all, here is the next topic: Environment configuration (because I was developed under Windows 8.1, so here only to talk about Windows).

    1. Installing Nodejs

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

After installation, you can use SHIFT + right-click to open cmd under the currently installed folder, 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 as the current user directory, but sometimes themselves for convenience will also be set under, here are the commands to set the following to see the following:

NPM config ls//list prefix configuration
NPM config set cache ' D:\Program Files\nodejs\node_cache '//Set global cache folder
NPM config set cache ' Node_global '//Set Global module folder

Third, the installation module

Now that we have node and NPM installed, NPM, as its name implies, is node's package Manager, which is managed by command, now try it:

Let's install a Web framework Express, the parameter-G representation is installed in the Global folder, and if it is not, it represents the current folder

NPM Install Express-g//express can also bring the @ version number

We are now looking under the folder we just set up, is there some more files Ah, here we use the command to view the version number of the Express installed just now

Express-v

If there is an output version on behalf of the installation succeeded!

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

NPM Uninstall Express

After this uninstall we install back to express, but back with the version number 3.2.2 (because I know the most familiar version is this), so will it?

Third, use Express installation

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

Express Test

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

Node App.js

See Prompt no, Port 3000 description started successfully, but our browser browse error, prompt what

-Error:cannot find module ' Jade '

That unexpectedly has the prompt error, then we now to install this module, here explained, this folder has a Package.json file, this file describes some of the site information, we can use Nodepad open to see:

It is clear that requires 2 libraries, one is express, one is jade, then we now install it, if many modules are not installed to execute a lot of commands, here is a simple command, it will check the current Package.json dependent library for installation:

NPM Install

Install this module we also need to modify the views under the Layout.jade file of the first line of DOCTYPE 5 to change to DOCTYPE HTML. This way, we can then re-execute node app.js and the site will work.

Iv. installation of Supervisor plug-in

Just now we may have found that if there is a problem, Nodejs automatically stop 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 those that are very useful. Install the global module using the following command:

NPM Install Supervisor-g

This allows us to start the service without the node command and use Supervisor App.js directly.

V. Use of the Webstorm IDE

Just now we edit JS file is to use Nodepad, but this is not very good, there is a good editor, the answer is, a name top of the Webstorm, many of the online version of the download, we understand, here also provide a link to the Netizen http://yunpan.cn/ CACF6HVXNIBCT extract Code 246f, download the direct installation, after the installation of an EXE file can be, Dick wire so simple!

The first run is to open a folder, which is actually the project's folder.

Below the debugging problem, including I also engaged in a long time online also looked for a long time, finally in Pogo would said to fix, this is actually difficult simple, directly look at the picture:

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

This record is first here, also a little late, the rest of the problem can be directly back to the next!!

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.