各种命令操作

Linux:

[root@iZ94bojtvkpZ nodejs-6.2.2]# cd /data/nodejs-6.2.2/ [root@iZ94bojtvkpZ nodejs-6.2.2]# ./use_nodejs #进入nodejs命令行环境 bash-4.2#

Windows:进入C:websoft9nodejs-6.2.2目录,双击执行use_nodejs,进入nodejs命令行环境。

然后,就可以进行如下操作了:

—————————————————————————————————————————

How to install modules?

In these cases, the command varies slightly:

$ npm -g install _PACKAGE_

For example, to install Express, you would execute:

$ npm -g install express

This will make the Express command-line available in all projects.

How to create a project using Express?

Installing it is as simple as starting the Bitnami console and then executing the command below:

$ npm -g install express
$ npm -g install express-generator

Create a skeleton project by executing these commands. This will produce a new application in the projects/sample-application directory:

Then, install dependencies using npm:

This will download and install the required dependencies into a node_modules directory under your project folder.

How to start the Express web application ?

To start your application, you just have to start the Bitnami console and then execute the following command, inside your application directory:

If you are using a recent Express version (greater than 4.0), you should use the following commands instead:

Port 3000 is the default port used by Express when creating the template. This means that you may receive an error similar to the below when starting the server:

This means that the port is already in use. Edit the app.js script and change the line below:

Specify a different port number, as in the example below:

Then, start the application again.

How to list the installed modules?

To list the modules installed locally in a project, enter the project directory and execute the npm list command, as shown in the example below. Remember to start the Bitnami console first if using a native installer.

You can also list the globally installed packages by entering the project directory and executing the npm -g list command, as shown below:

How to upgrade NPM?

You can upgrade npm to the latest version with the following command:

Installing Node.js applications?

NOTE: To avoid a conflict between two or more Node.js applications attempting to use the same port, modify the application settings as needed to use a different port for each application.

To install a Node.js application, first ensure that all dependences are satisfied. Many applications will require Node.js and MongoDB, but others may require Redis or MySQL. To check available services, run this command:

To install an application in the _example/ _directory, first create the directory:

Then, move the application files to that directory and follow the official installation steps.

Version 1.0.0

Last updated