Basics of Nodejs and Expressjs in SAP BAS

A very basic of initialising node and express in SAP BAS project.

  1. Create a full stack dev space. Lets call it “node”.

kiran_israni3_0-1717657804996.png

 

2. Open the dev space. Create empty folder “nodebasics1” in workspace.

kiran_israni3_1-1717657805007.png

3. Right click and open integrated terminal.

kiran_israni3_2-1717657805014.png

 

4. Run the first command “npm init”. This is the very first command to be executed when setting up any node project.

kiran_israni3_3-1717657805020.png

 

5. After executing command, it will ask few details on package name, licence, description, author, entry point(starting file), etc. Provide the details if required, else, press keep pressing enter.

 

kiran_israni3_4-1717657805029.png

 

6. After this, a package.json file is created. This will have all the details , as mentioned in step 5.  We can change anytime later.

kiran_israni3_5-1717657805040.png

 

7. Now install Express package using command “npm install express”.

kiran_israni3_6-1717657805047.png

 

 

8. Once downloaded, you will notice below changes in project structure and package.json

kiran_israni3_7-1717657805061.png

 

9. Since the mail file is index.js, right click on project “nodebasics1”, and create a new file named as “index.js”.

kiran_israni3_8-1717657805071.png

 

 

kiran_israni3_9-1717657805075.png

 

 

kiran_israni3_10-1717657805082.png

 

10. Copy the code from https://www.npmjs.com/package/express and paste it in index.js.

kiran_israni3_11-1717657805088.png

 

 

kiran_israni3_12-1717657805096.png

 

11. Now execute the command “node .[Notice the space in between node and .]

kiran_israni3_13-1717657805100.png

 

 12. Possibility of error here, “Port is already in use”.

kiran_israni3_14-1717657805106.png

 

 

If an error comes, change the port number. I am changing it to 3004 for now. Execute node . again.

 

kiran_israni3_15-1717657805110.png

 

13. Once executed successfully, a pop up in bottom right corner will come. Open in new tab.

kiran_israni3_16-1717657805122.png

 

 

kiran_israni3_17-1717657805127.png

 

14. To change the message or any changes, stop the server by closing the tab and executing Ctrl+C in integrated terminal. When Ctrl C is executed, it will show as ^C.

kiran_israni3_18-1717657805129.png

 

 15. Change the message and execute again with node . .

 

kiran_israni3_19-1717657805140.png

16. Open the server.

kiran_israni3_20-1717657805146.png

 

 

WelcomeWelcome

 

 

 

Scroll to Top