Step by Step nodejs installation on Linux 7.9 with ODA and custom component
Published Jan. 2, 2025, 10:44 a.m. by cloudblog
Here is a step-by-step guide to install Node.js on Oracle Linux 7.9 for running external functionalities in an ODA (Oracle Digital Assistant) custom component:
Step 1: Update System Packages
sudo yum update -y
Step 2: Enable Node.js Module
Oracle Linux 7 uses Software Collections (SCL) to provide newer versions of software.
1. Enable Developer Tools and Extra Packages:
sudo yum install -y oracle-epel-release-el7 sudo yum-config-manager --enable ol7_optional_latest
2. Install NodeSource Repository:
For the latest LTS (Long-Term Support) version of Node.js (e.g., 18.x):
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
Alternatively, for Node.js 16.x:
curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
Step 3: Install Node.js
sudo yum install -y nodejs
Verify the installation:
node -v npm -v
Step 4: Install Required Build Tools (Optional)
Some Node.js modules require compilation, so install gcc-c++ and make:
sudo yum install -y gcc-c++ make
Step 5: Install the Oracle Digital Assistant SDK
- Create a project directory:
mkdir oda-custom-component cd oda-custom-component
- Initialize the project:
npm init -y
- Install the Oracle Bot SDK:
npm install --save @oracle/bots-node-sdk
Step 6: Build Your Custom Component
- Create the customComponent.js file:
nano customComponent.js
- Add sample code:
'use strict'; module.exports = { metadata: () => ({ name: 'exampleComponent', properties: { input: { type: 'string', required: true } }, supportedActions: ['success', 'error'] }), invoke: (context, done) => { let input = context.properties().input; if (input) { context.reply(`Received input: ${input}`); context.transition('success'); } else { context.transition('error'); } done(); } };
Step 7: Test the Component
node customComponent.js
Step 8: Deploy the Component
You can now deploy the component to Oracle Digital Assistant by packaging it and uploading it to the custom component server in Oracle Cloud.
Useful Commands:
- Check Node.js Version:
node -v
- Check NPM Version:
npm -v
- List Installed Packages:
npm list
- Install Additional Libraries:
npm install <library_name>
Error: Package: 2:nodejs-18.20.5-1nodesource.x86_64 (nodesource-nodejs) Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit) Error: Package: 2:nodejs-18.20.5-1nodesource.x86_64 (nodesource-nodejs) Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit) Error: Package: 2:nodejs-18.20.5-1nodesource.x86_64 (nodesource-nodejs) Requires: libc.so.6(GLIBC_2.28)(64bit) Error: Package: 2:nodejs-18.20.5-1nodesource.x86_64 (nodesource-nodejs) Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
The error occurs because the Node.js 18.x version requires a newer version of glibc
and libstdc++
than the ones available in Oracle Linux 7.9 by default.
Solution 1: Install Node.js 16.x (Recommended for Oracle Linux 7)
- Clean any previous attempts:
sudo yum clean all sudo rm -rf /var/cache/yum
- Install Node.js 16.x instead of 18.x, which has lower dependencies:
curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash - sudo yum install -y nodejs
- Verify:
node -v npm -v
Solution 2: Upgrade glibc
and libstdc++
(Riskier)
Note: Proceed only if Node.js 18.x is mandatory. Upgrading system libraries can lead to compatibility issues with other packages.
Step 1: Check Current Versions
ldd --version strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
Step 2: Upgrade glibc
- Download and extract the newer version:
cd /usr/local/src sudo wget http://ftp.gnu.org/gnu/libc/glibc-2.28.tar.gz sudo tar -xvzf glibc-2.28.tar.gz cd glibc-2.28
- Build and install:
mkdir /usr/glibc-2.28 sudo ./configure --prefix=/usr/glibc-2.28 sudo make -j$(nproc) sudo make install
- Configure dynamic linker to use the new
glibc
:
sudo ln -sf /usr/glibc-2.28/lib/ld-2.28.so /lib64/ld-2.28.so sudo ldconfig
Step 3: Upgrade gcc
(if required)
sudo yum install -y centos-release-scl sudo yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
Step 4: Verify Dependencies Again
ldd --version strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
Final Check
Retry installing Node.js:
sudo yum install -y nodejs
$ npm install --save @oracle/bots-node-sdk
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
added 53 packages, and audited 54 packages in 9s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 8.19.4 -> 11.0.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.0.0
npm notice Run npm install -g npm@11.0.0 to update!
npm notice
Similar posts
There are no similar posts yet.2 comments
Comment 2 by coolsid Jan. 6, 2025, 5:36 p.m.
First of all you need to install node.js if you don't have it. You can download it in the followeing link: Node.js
Then you need to install Oracle Digital Assistant node sdk. Open a Command Prompt or a Terminal and execute the follwing commands.
npm install -g @oracle/bots-node-sdk
Now you can create the folder for our component.
mkdir weather-component
And go to that folder.
cd weather-component
Then you need to initialize our component. As it is a node.js application, you need to create package.json file. '-y' options means no questions are asked and the file is created with default values (Just for the hands-on, in your real projects you will assign the right values)
npm init -y
Then you need to configure the SDK into our project.
bots-node-sdk init
Request module will enable you to make service calls. THis module is deprecated and for production usage you should consider other modules like https (part of Node code), Axios or Alike.
npm install --save request
You also need to install moment js module to easily display the date provided by the user in a specific format.
npm install --save moment
Running the service and configuring it in Oracle Digital Assistant
The implementation is now finished and you are ready to execute the service so it can be consumed from the dialogflow. You will start the service in your computer by using:
bots-node-sdk service -P 3000
Now that you have the service up and running, you have to expose the service using ngrok, otherwise it would be available only in your machine. You can download ngrok in the following link: Download ngrok
Open a terminal an execute:
ngrok http 3000
Comment 1 by coolsid Jan. 6, 2025, 3:43 p.m.
Install Python 3.8
1. Enable the Software Collections Repository
Run the following to enable the appropriate repository for Oracle Linux 8:
sudo dnf config-manager --set-enabled ol8_codeready_builder
sudo dnf clean all
sudo dnf makecache
2. Try Installing the Package Again
sudo dnf install -y rh-python38
3. If the Package Still Isn't Found:
Check if the oracle-softwarecollection-release-el8 package is installed:
sudo dnf list installed | grep oracle-softwarecollection
If it isn’t installed, try installing it:
sudo dnf install -y oracle-softwarecollection-release-el8
After that, retry:
sudo dnf install -y rh-python38
Alternative: Install Python 3.8 Directly
If rh-python38 isn't available, you can install Python 3.8 directly from the AppStream or EPEL repository:
sudo dnf install -y python38
Confirm the installation:
python3.8 --version
Now download the correct ARM64 version:
curl -O https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-arm64.tar.xz
tar -xvf node-v22.12.0-linux-arm64.tar.xz
sudo mv node-v22.12.0-linux-arm64 /nodes/spva/node-v22.12.0-linux-arm64
Symlink the Correct Node.js and npm:
sudo ln -sf /nodes/spva/node-v22.12.0-linux-arm64/bin/node /usr/bin/node
sudo ln -sf /nodes/spva/node-v22.12.0-linux-arm64/bin/npm /usr/bin/npm
Verify:
node -v
npm -v
If these commands show the expected version, retry the Oracle SDK install:
npm install -g @oracle/bots-node-sdk