quickly generate a development framework? The first is to use tools. I use webstorm, and the other is syntax, use commands to operate on the workspace, and then run the command express-e aTest (where-e refers to ejs, and aTest is the project name and the top folder name). In order to be visualized, we still use tools to generate.
1: A new project, all kinds of development started from here
2: select a node Project
3: select the version number and d
node. JS callback functionThe immediate manifestation of node. JS asynchronous programming is callbacks.Asynchronous programming relies on callbacks to implement, but it cannot be said that the program is asynchronous after using the callback.The callback function is called after the task is completed, and
This article mainly introduces Node. for details about js file operations, this article describes how to process file paths and how to use and introduce the fs module in detail. For details, refer to a set of data flow APIs on Node, it is convenient to process files like network streams, but it only allows sequential processing of files and does not allow random
a file, we recommend that you first determine whether the file exists and then overwrite it.
Use Shell scripts
According to the API functions provided by Node. js, some people prefer to use Shell scripts for file operations. Fortunately, we can also introduce node-cmd in our scaffolding to enable support for Shell scripts. Run npm install
Recently written program node. data storage is required for js programs. there are many databases that js can use, such as mongodb and MySQL. However, I still think these databases are too large to be useful, making them more troublesome. So I found node-tiny, a non-relation
defined as:var EE = require (' Events '). Eventemitter;var util = require (' util '); Util.inherits (stream, EE); function Stream () { ee.call (this);}As you can see, stream is essentially a eventemitter, which means it has event-driven functionality (. Emit/.on ... )。 As we all know, "node. JS is a V8-based event-driven platform" that implements event-driven streaming programming with the characteristics
This article mainly introduces how to use Node. js to implement content sharding in HTTP206. Node. js is a JavaScript framework for servers. For more information, see
Introduction
In this article, I will describe the basic concept of HTTP status 206, and use Node.
Some resultsSort: Sorting the resultsFields: Returns only the specified fieldMongoDB can conveniently put some of the data that MySQL needs to be associated with a one-to-many relationship through an array + object as a document stored in a collections, and provides a variety of APIs to support the operation of an array within a document.MongoDB often uses query methods with the embodiment in node:1. Database connection mongodb:mongo-u username-p pas
This article mainly introduces how to use Node. js to implement content sharding in HTTP206. Node. js is a JavaScript framework for servers. For more information, see
Introduction
In this article, I will describe the basic concept of HTTP status 206, and use Node.
Code as follows:
The Code is as follows:
Var EE = require ('events'). EventEmitter;Var util = require ('til ');Util. inherits (Stream, EE ); Function Stream (){EE. call (this );}
It can be seen that Stream is essentially an EventEmitter, which means it has the event-driven function (. emit/. on ...). As we all know, "Node. js is an event-driven platform based on V8". It implements event-driven stream pro
Introduction to the use of _ dirname in Node. js, node. js _ dirname
Preface
This article mainly introduces the use of _ dirname in Node. js for your reference. Let's take a look at the details below:
The method is as follows:
directory, such as/node. js, and set the permission to 754, which can avoid the trouble caused by some permission problems!
Because the Ubuntu Server system is used, the MongoDB startup service is configured above, and the following statements are added to its init. d script:
# Required-Start: $all# Required-Stop: $allTherefore, the system will prompt an
This article mainly introduces Node. js uses the dependency injection-related issues and solutions, Node. js is a framework that runs JavaScript applications on the server. if you need JavaScript, refer to the recent introduction. I turn to dependency injection to help you understand the simple way to separate code and
This article mainly introduces Node. js uses the dependency injection-related issues and solutions, Node. js is a framework that runs JavaScript applications on the server. If you need JavaScript, refer to the recent introduction. I turn to dependency injection to help you understand the simple way to separate code and
printHello () {console. log ("Hello, World! ");} // After two seconds, execute the above setInterval (printHello, 2000) function );
Process a simple interface with the operating system
Process is a global variable, that is, the attribute of the global object.
It is used to describe the status of the current Node. js process and provides a simple interface with the operating system. When you write a local c
)$/ig, maxAge: 60*60*24*365};exports.Compress = { match: /css|js|html/ig};exports.Welcome = { file: "index.html"};
Lists the types of various resources. You can set the Content-Type according to the extension.
exports.types = { "css": "text/css", "gif": "image/gif", "html": "text/html", "ico": "image/x-icon", "jpeg": "image/jpeg", "jpg": "image/jpeg", "js": "text/javascript", "json": "application/json", "pd
This article describes how to get the Buffer object byte length from the Node. js practical code segment. For more information, see what we know under the Node. js framework.
Buffer objectIt can provide good support for binary data, so it is necessary to obtain the actual length of bytes of a Buffer object. The
function supports the third form of path, which is similar to foo/bar, and resolves the path according to the following rules until the module location is found.
Built-in modules
If the node. js built-in Module name is passed to the require function without path parsing, the export object of the internal module is directly returned, for example, require ('fs ').
The console. trace Method in node. js is used in node. js scenarios.
Method description:
Outputs the current call stack to the standard error stream.
Syntax:
Copy codeThe Code is as follows:Console. trace (label)
Receiving parameters:
Label
Example:
Copy codeThe Code is as f
();} res. send (B. num) ;}); function flush () {delete require. cache [path. join (_ dirname ,'. /B. js ')]; B = require ('. /B. js ');} app. listen (0, 3000 );
Before re-require, clear the cache for the module above require and test again with the previous method. The result shows that the code of B. js can be refreshed successfully and the new value can be out
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.