Nodejs+mongodb+angularjs's Way of learning the first chapter

Source: Internet
Author: User
Tags wrapper

1.nodejs Installation

Installation location: node for launching a nodejs JavaScript engine

NPM: You can use this command to manage NODEJS packages

Node_modules: The folder contains the installed Nodejs package

NPM Command line Options

Find a package: NPM search NPM Package Name

Installation package: NPM Install NPM package name

2. Encapsulation of the module

So the node module must contain a Package.json file in its root directory, which can contain several different instructions to tell node how the package Manager handles the module.

3. Create a node application

After writing the module, you need to have Package.json, README. MD is a descriptive file that can be written casually.

Encapsulation Module command: NPM Pack generates a file with the suffix tgz

4. Publish a node wrapper module to the NPM registry

1 Create a common repository that contains the code for the module, for example, on GitHub Https://github.com/node/nodebook/nodeDB

2 Create an account in Https://npmjs.org/signup

3 Add the created user to the environment with a command

NPM AddUser Enter your account password email

4 Modify the Package.json to add and improve the good information

5 Release the module using NPM Publish in the console of the project

Once published, you can download and search

Unpublish NPM unpublish project name

In some cases, if the--force option is not applicable, you will not be able to unpublish the module, which forces the module to be clear and removed from the registry.

NPM unplish Node Package--force

5. Using the node wrapper module in the node application

Require (' node package ')

Require ('./lib/util.js ') Note: The extension is optional

6 Speaking data write to console

Because the console module is very versatile, you do not need to use require () he loads into your module you just need to use the console. Functions (Parameters)

Nodejs+mongodb+angularjs's Way of learning the first chapter

Related Article

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.