What’s this about?
I want to have a node.js environment on my notebook so I can try out some ideas or gain understanding of new modules before integrating into a bigger project.
Inspired by Open SAP courses like “SAP Cloud Platform Essentials (Update Q2/2019)” and “Software Development on SAP HANA (Update Q1/2019)” I decided to look into developing with node.js. Besides the advantages of SAP Web IDE I need an environment which runs on my notebook and can be used as standalone sandbox. When you’re travelling a lot by train your belief in cloud technologies is not as strong as it might be, by the way. I also like the blog “Developing with HANA Deployment Infrastructure (HDI) without XSA/CF or Web IDE” by Thomas Jung but I wanted something with an even smaller footprint.
Note: This is NOT a tutorial for any of those tools nor in developing. It just shows how to set up a playground for node.js. I use it e.g. to figure out how regular expression work if I need it, or some other packages which I never used before.
Of course you can find a lot of useful tutorials, samples and other stuff on the net.
Let’s do it
So I decided about the tools and the directory structure. To me it’s important that everything can run without administrator privileges on my Windows PC. That’s why all tools are below C:\Users\student\dev and these are my choices (you can search Google for the key words):
- Portable Git: The door of my sandbox (https://git-scm.com/download/win) – use 64-bit Git for Windows Portable
- Visual Studio Code: More than a simple editor. I also tried Eclipse but this is not as lightweight as I like it ;o) (https://code.visualstudio.com/)
- Node.js (https://nodejs.org/)
When building the directory structure I omit version numbers and suffixes like win32x86. I don’t need it and updates will be applied in-place. After downloading and unzipping it looks like this:
I recommend setting up and running the first test when you’re enjoying a fast internet connection.
Double-clicking dev.bat sets up the environment by adding the tools the path. Let’s check it:
@echo off set HOME=C:\Users\student set PATH=%PATH%;%HOME%\dev\node;%HOME%\dev\VSCode;%HOME%\dev\PortableGit\bin set HOMEDRIVE=C: cmd
From the opened command processor check the versions and commands like this:
Now let’s get a project with git, the project is from an opensap course:
cd projects git clone https://github.com/SAP/cloud-sample-node-chat
Let’s edit the project:
Now we open a terminal inside code:
Let’s fetch the dependencies:
And run it:
Great, it just runs. But when we open app.js within VS Code then we suddenly see an error message (right-down corner marked in yellow).
The reason is we miss something, clicking on “Go to output” provides the necessary hint:
We can copy the suggested command, switch to the TERMINAL tab and run it (maybe you must stop your running node.js by pressing CTRL-C).
To initialize ESLint just type “eslint –init”
Great! Errors resolved, looks good.
Of course you can check if everything is running fine with a “Hello World” app as found e.g. in https://code.visualstudio.com/docs/nodejs/nodejs-tutorial. There are also some nice extensions described in https://code.visualstudio.com/docs/nodejs/extensions.
Or just follow your own ideas.