A very basic of initialising node and express in SAP BAS project.
- Create a full stack dev space. Lets call it “node”.
2. Open the dev space. Create empty folder “nodebasics1” in workspace.
3. Right click and open integrated terminal.
4. Run the first command “npm init”. This is the very first command to be executed when setting up any node project.
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.
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.
7. Now install Express package using command “npm install express”.
8. Once downloaded, you will notice below changes in project structure and package.json
9. Since the mail file is index.js, right click on project “nodebasics1”, and create a new file named as “index.js”.
10. Copy the code from https://www.npmjs.com/package/express and paste it in index.js.
11. Now execute the command “node .” [Notice the space in between node and .]
12. Possibility of error here, “Port is already in use”.
If an error comes, change the port number. I am changing it to 3004 for now. Execute node . again.
13. Once executed successfully, a pop up in bottom right corner will come. Open in new tab.
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.
15. Change the message and execute again with node . .
16. Open the server.