Node.js packages are available using NPM, which is the standard package manager for Node.js.
-
Enter @sap/hana-client
, and click Search.
The page for the SAP HANA Node.js package on npm is shown below.
It contains additional sample code, a weekly download counter, information about previous versions and the command to install the package using the npm command line interface (cli
).
-
Create a folder named node
and enter the newly created directory.
mkdir %HOMEPATH%\HANAClientsTutorial\node
cd %HOMEPATH%\HANAClientsTutorial\node
mkdir $HOME/HANAClientsTutorial/node
cd $HOME/HANAClientsTutorial/node
-
Initialize the project and install the hana-client
driver from NPM.
npm init -y
npm install @sap/hana-client
The hana-client driver is also available from the HANA client install folder. The install location was set during the install.
npm install C:\SAP\hdbclient\node
If you encounter an error about permissions, on Microsoft Windows, run or open the command prompt as an administrator, or use sudo
on Linux or Mac.
-
The following command will list the Node.js modules that are now installed locally into the HANAClientsTutorial\node
folder. Note that the extraneous message can be ignored.
npm list
Some Tips
At this point, the SAP HANA client module has been installed into the HANAClientsTutorials\node\node_modules
folder and added as a dependency in the packages.json
file. The following is some extra optional information on NPM.
Node.js modules can also be installed globally. To see the list of node modules installed globally enter the following command.
The depth parameter can be used to specify the number of levels to show when displaying module dependencies. By setting depth=x, a tree-structure is outputted that shows modules that are x levels below the top-level module.
npm list -g
npm list -g --depth=0
Command line help for NPM is available. A few examples of this are shown below.
npm help
npm help list
Additional information can be found out for a module, such as the debug module, via the info command.
npm info @sap/hana-client
The following commands can be used to view the latest available version of a package, remove a package, add a specific version of a package and then update it to the latest version.
npm view @sap/hana-client version
npm uninstall @sap/hana-client
npm install @sap/hana-client@2.4.167
npm list @sap/hana-client
npm update @sap/hana-client
npm list @sap/hana-client