Getting started with Node.jsnpmWeb Apps With ExpressFilesystem I/OExporting and Consuming ModulesExporting and Importing Module in node.jsInstalling Node.jsMySQL integrationReadlinepackage.jsonEvent EmittersAutoreload on changesEnvironmentCallback to PromiseExecuting files or commands with Child ProcessesCluster ModuleException handlingKeep a node application constantly runningUninstalling Node.jsnvm - Node Version ManagerhttpUsing StreamsDeploying Node.js applications in productionSecuring Node.js applicationsMongoose Libraryasync.jsFile uploadSocket.io communicationMongodb integrationHandling POST request in Node.jsSimple REST based CRUD APITemplate frameworksNode.js Architecture & Inner WorkingsDebugging Node.js applicationNode server without frameworkNode.JS with ES6Interacting with ConsoleCassandra IntegrationCreating API's with Node.jsGraceful ShutdownUsing IISNode to host Node.js Web Apps in IISCLINodeJS FrameworksgruntUsing WebSocket's with Node.JSmetalsmithParsing command line argumentsClient-server communicationNode.js Design FundamentalConnect to MongodbPerformance challengesSend Web NotificationRemote Debugging in Node.JSMysql Connection PoolDatabase (MongoDB with Mongoose)Good coding styleRestful API Design: Best PracticesDeliver HTML or any other sort of fileTCP SocketsHackBluebird PromisesAsync/AwaitKoa Framework v2Unit testing frameworksECMAScript 2015 (ES6) with Node.jsRouting ajax requests with Express.JSSending a file stream to clientNodeJS with RedisUsing Browserfiy to resolve 'required' error with browsersNode.JS and MongoDB.Passport integrationDependency InjectionNodeJS Beginner GuideUse Cases of Node.jsSequelize.jsPostgreSQL integrationHow modules are loadedNode.js with OracleSynchronous vs Asynchronous programming in nodejsNode.js Error ManagementNode.js v6 New Features and ImprovementEventloopNodejs Historypassport.jsAsynchronous programmingNode.js code for STDIN and STDOUT without using any libraryMongoDB Integration for Node.js/Express.jsLodashcsv parser in node jsLoopback - REST Based connectorRunning node.js as a serviceNode.js with CORSGetting started with Nodes profilingNode.js PerformanceYarn Package ManagerOAuth 2.0Node JS LocalizationDeploying Node.js application without downtime.Node.js (express.js) with angular.js Sample codeNodeJs RoutingCreating a Node.js Library that Supports Both Promises and Error-First CallbacksMSSQL IntergrationProject StructureAvoid callback hellArduino communication with nodeJsN-APIMultithreadingWindows authentication under node.jsRequire()Route-Controller-Service structure for ExpressJSPush notifications

Interacting with Console

Other topics

Logging

Console Module

Similar to the browser environment of JavaScript node.js provides a console module which provides simple logging and debugging possibilities.

The most important methods provided by the console module are console.log, console.error and console.time. But there are several others like console.info.

console.log

The parameters will be printed to the standard output (stdout) with a new line.

console.log('Hello World');

enter image description here

console.error

The parameters will be printed to the standard error (stderr) with a new line.

console.error('Oh, sorry, there is an error.');

enter image description here

console.time, console.timeEnd

console.time starts a timer with an unique lable that can be used to compute the duration of an operation. When you call console.timeEnd with the same label, the timer stops and it prints the elapsed time in milliseconds to stdout.

enter image description here

Process Module

It is possible to use the process module to write directly into the standard output of the console. Therefore it exists the method process.stdout.write. Unlike console.log this method does not add a new line before your output.

So in the following example the method is called two times, but no new line is added in between their outputs.

enter image description here

Formatting

One can use terminal (control) codes to issue specific commands like switching colors or positioning the cursor.

enter image description here

General

EffectCode
Reset\033[0m
Hicolor\033[1m
Underline\033[4m
Inverse\033[7m

Font Colors

EffectCode
Black\033[30m
Red\033[31m
Green\033[32m
Yellow\033[33m
Blue\033[34m
Magenta\033[35m
Cyan\033[36m
White\033[37m

Background Colors

EffectCode
Black\033[40m
Red\033[41m
Green\033[42m
Yellow\033[43m
Blue\033[44m
Magenta\033[45m
Cyan\033[46m
White\033[47m

Syntax:

  • console.log([data][, ...])
  • console.error([data][, ...])
  • console.time(label)
  • console.timeEnd(label)

Contributors

Topic Id: 5935

Example Ids: 20818

This site is not affiliated with any of the contributors.