Skip to Content
Technical Articles
Author's profile photo Yohei Fukuhara

How to deploy Node.js application into SAP Cloud Platform CF

Hi All,

I am writing this blog to describe some easy steps to deploy a Node.js application into the SAP cloud foundry environment.

It is the first time for me to setup Node.js environment, so there may be some mistakes on this article.



Local PC

  • Ubuntu18.04.01 LTS on VMWare Workstation
  • cf CLI 6.43.0
  • node.js 11.10.1
  • npm 6.7.0

Cloud Foundry

  • Nodejs Buildpack version 1.6.40
  • CF Trial (Europe – Frankfurt)


  • your space is created on Cloud Foundry environment
  • cf CLI is installed on Local PC(see the official page for the installation)


1. Install Node.js

Since I have never used Node.js on my local PC, I installed Node.js first.

# Install Node.js using PPA
curl -sL | sudo -E bash -
apt show nodejs
sudo apt install nodejs

# Check if it is successful
node --version
nmp --version


2. Run Hello world for checking Node.js

# Create a folder
mkdir sample && cd sample

# Create hello.js, which shows just "Hello world"
echo 'console.log("Hello, World!");' > hello.js

# Run
node hello.js


3. Clone sample repository

Clone sample repository from GitHub.

# Clone repository
git clone -b 1_REST_persist_in_Memory
cd cloud-cf-helloworld-nodejs

# configure npm
npm config set @sap:registry

# npm instll
npm install
npm install --save express body-parser axios


4. Try Node.js on local PC

Run Node.js and see the result via browser.

# From directry of cloned
nodejs server.js


Open URL via browser.



5. Deploy the app into Cloud Foundry

Using CF CLI, login and deploy the app into Cloud Foundly

cf api
cf login

# From directory of cloned repository
cf push sample-nodejs

Successfully deployed!

Now it works on Public internet space.




Node.js dependent information is in package.json.

  "name": "SAP-CP-CF-HelloWorld",
  "description": "Sample SAP-CP-CF Hello World Restful Service",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "4.15.3",
    "body-parser": "1.17.2"
  "engines": {
    "node": "6.x.x"
  "scripts": {
    "start": "node server.js"


Cloud Foundry dependent information is in manifest.yml.

- name: sapcpcfhw
  path: .
  buildpack: nodejs_buildpack
  memory: 128M

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Braiden Psiuk
      Braiden Psiuk

      Hi there, awesome tutorial! However, I had a bit of trouble getting everything compiled properly and uploaded to Cloud Foundry. I would like to share the steps I took to fix these issues.


      Before Step 5 in this Article:

      1. Get your current version of node by running:
        node -v
        remember this version number by writing it down or copying it
      2. Make sure you are inside the /cloud-cf-helloworld-nodejs folder
      3. Run the following command to open “package.json” with the nano text editor:
        nano package.json
      4. Under “engines”, change “node” from 6.x.x to your current version of node
        It is not recommended, but you can also change this to x.x.x if you are still having problems
      5. Press CTRL-X and press Y to save changes
      6. Run the following command:
        cf push NAME_OF_YOUR_APP -b
        Rename your app to something unique. You may get an error if somebody else has already taken the name


      Remember, it will not work correctly if you are not inside the /cloud-cf-helloworld-nodejs folder.

      If you followed everything correctly, it should now compile successfully because the correct version of node has been set and a buildpack is specified. Hopefully this helped!

      Author's profile photo Braiden Psiuk
      Braiden Psiuk

      There are a few other things to note as well after following this tutorial:

      Increasing the Memory Size for your App:

      1. Run the following:
        nano manifest.yml
      2. Change the memory size from “128M” to “512M” or something larger if you need it.
        If you are working with a trial account, you have 4GB available so you can safely bump this number up a little. But remember to save some in case you deploy other apps too
      3. Press CTRL-X and press Y to save changes

      Discovering your App’s Endpoint

      1. Go to your Cloud Foundry “dev” space
      2. Click on your app from within the Cloud Foundry “Applications” view
      3. Find your endpoint under “Application Routes”
      4. You can visit this endpoint in a browser to test your app. Just remember to put "/users" after your endpoint, or else you will get a "Cannot GET /" error
      Author's profile photo Minjie Lao
      Minjie Lao

      Hi there,


      Do we have any limitation of using any template engineer (like ejs ) on the cloud platform?


      I tried to deploy one which is working find on my local machine, but facing internal server error after deploy to cloud foundry

      Author's profile photo Yohei Fukuhara
      Yohei Fukuhara
      Blog Post Author



      I have no idea.  I cannot help you.




      Author's profile photo Minjie Lao
      Minjie Lao

      Hi Yohei,


      No worries, it does support the engine.


      I was misleading by some other issue and thought it was not supported.