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

Autoreload on changes

Other topics

Autoreload on source code changes using nodemon

The nodemon package makes it possible to automatically reload your program when you modify any file in the source code.

Installing nodemon globally

npm install -g nodemon (or npm i -g nodemon)

Installing nodemon locally

In case you don't want to install it globally

npm install --save-dev nodemon (or npm i -D nodemon)

Using nodemon

Run your program with nodemon entry.js (or nodemon entry)

This replaces the usual use of node entry.js (or node entry).

You can also add your nodemon startup as an npm script, which might be useful if you want to supply parameters and not type them out every time.

Add package.json:

  "scripts": {
    "start": "nodemon entry.js -devmode -something 1"
  }

This way you can just use npm start from your console.

Browsersync

Overview

Browsersync is a tool that allows for live file watching and browser reloading. It's available as a NPM package.

Installation

To install Browsersync you'll first need to have Node.js and NPM installed. For more information see the SO documentation on Installing and Running Node.js.

Once your project is set up you can install Browsersync with the following command:

$ npm install browser-sync -D

This will install Browsersync in the local node_modules directory and save it to your developer dependencies.

If you'd rather install it globally use the -g flag in place of the -D flag.

Windows Users

If you're having trouble installing Browsersync on Windows you may need to install Visual Studio so you can access the build tools to install Browsersync. You'll then need to specify the version of Visual Studio you're using like so:

$ npm install browser-sync --msvs_version=2013 -D

This command specifies the 2013 version of Visual Studio.

Basic Usage

To automatically reload your site whenever you change a JavaScript file in your project use the following command:

$ browser-sync start --proxy "myproject.dev" --files "**/*.js"

Replace myproject.dev with the web address that you are using to access your project. Browsersync will output an alternate address that can be used to access your site through the proxy.

Advanced Usage

Besides the command line interface that was described above Browsersync can also be used with Grunt.js and Gulp.js.

Grunt.js

Usage with Grunt.js requires a plugin that can be installed like so:

$ npm install grunt-browser-sync -D

Then you'll add this line to your gruntfile.js:

grunt.loadNpmTasks('grunt-browser-sync');

Gulp.js

Browsersync works as a CommonJS module, so there's no need for a Gulp.js plugin. Simply require the module like so:

var browserSync = require('browser-sync').create();

You can now use the Browsersync API to configure it to your needs.

API

The Browsersync API can be found here: https://browsersync.io/docs/api

Contributors

Topic Id: 1743

Example Ids: 5642,7183

This site is not affiliated with any of the contributors.