What is Node JS Salesforce?

This blog will introduce you to Salesforce nodejs. I will take you through Node and its environment setup for developing your first application. Node is an open-source, cross-platform runtime environment for executing the JavaScript code. For Node you must be acquainted with JavaScript, HTML and CSS and also have some familiarity with web applications and the MVC concept. It’s built on the Google V8 JavaScript engine and V8 compiles JavaScript code to native machine code.

Before salesforce nodejs, JavaScript was only executed in browsers. In 2009 Ryan Dahl used open-source Google V8 JavaScript engine to build Node as a runtime environment for JavaScript outside a browser.

So using Node it is possible to use JavaScript as a server side language.

By using Node we can develop the MVC based web applications. With Node, however, you use JavaScript everywhere, on the server side as well as on the client side.

For more information about Node follow the link below:

Setting up the Environment

I took the reference of the given link

For developing a node js salesforce based application there are a few tools, which we have to install in our system. Here is a list of some basic tools which we need for Node application.

Install Text editor to build your code. Here is a list of text editor which you can install on your system.

Or you can use your Notepad editor.

Install MongoDB

After installing Mongo either you can run it from command prompt or window service.

Install Node by going to the given link you will get NPM (Node Package Manager) on your machine. By using NPM we can download packages/modules in our applications.

Install Express Generator

Express Generator is a node js salesforce module that we use to scaffold (platform) an application. To install Express Generator open a new Command Prompt and run the given command

Npm install -g express-generator

Create a platform of your project which you want to develop using Node.

Enter the given command on command prompt after installing Express Generator,

Express project Name

Example: – express hello here hello is my project name.

Now open your project in your favorite text editor and the directory structure of your application will be like this:-

node js salesforce

node js salesforce

salesforce nodejs

Public is where we store public assets of our website, such as Javascript files, stylesheets, images etc.

node js salesforce

Routes defines an endpoint in your application where you receive requests.

salesforce nodejs

View includes the view files for your application. Express supports many popular template engine such as Jade, Html, EJS, and Handlebars etc. Jade is the default template engine for Node.

salesforce nodejs

App.js is the entry point to your application. It’s where your application is defined and configured. This is the controller of your application.

node js salesforce

Package.json this includes application metadata and identifies application dependencies. Here you will see your package.json structure:-

node js salesforce

Here we will specify name and the version of our application as well as its dependencies.

Install Dependencies

To install the dependencies, go to terminal or command prompt and run the following commands:

salesforce nodejs

Npm install

To know more about the packages follow the link below:

node_module is the folder in your application directory where all modules will be stored.

node js salesforce

Install Nodemon

To install Nodemon follow the given command

Npm install nodemon -g

When you start a Node application, a basic web server starts on port 3000 and accepts incoming requests. If you make any changes in your application, you need to restart your application server so this is a time taking process to start the server after every alteration. So in order to overcome we use Nodemon, which is another Node module that automatically restarts your web server whenever it detects any change in your source files.

Install Monk

Monk is a Node module for reading and writing documents in MongoDB

To install monk follow the given command

Npm install monk save

How to run your application?

For running this basic application run the following command on your project directory on command prompt

Go to project by using

Cd hello

Then enter the command to run application


Nodemon will start your web server on port 3000, as shown in the above image.

Now launch your browser and navigate the given link:


Here is your first express application.

salesforce nodejs

Posted in Node.JS. Tagged with , , .

Leave a Reply

Your email address will not be published. Required fields are marked *