Forum Discussion

jeffshurtliff's avatar
12 months ago

Errors installing lithium-sdk on RHEL 9.2

Hi all,

I have a new Red Hat Enterprise Linux (RHEL) 9.2 server on which I am trying to install the lithium-sdk node package, but it is failing with an error involving node-gyp.

Here is the full error:

npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/lithium-sdk/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c -- node scripts/build.js
npm ERR! Building: /usr/bin/node /usr/local/lib/node_modules/lithium-sdk/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/bin/node',
npm ERR! gyp verb cli   '/usr/local/lib/node_modules/lithium-sdk/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.20.1 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "/usr/bin/python3" in the PATH
npm ERR! gyp verb `which` succeeded /usr/bin/python3 /usr/bin/python3
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: /usr/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:402:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm ERR! gyp ERR! System Linux 5.14.0-284.11.1.el9_2.x86_64
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/lithium-sdk/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/lithium-sdk/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.20.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

 

Does anyone know how to solve this?  I've tried:

  • Manually installing phantomjs (which resolved a previous error)
  • Manually installing node-sass with this command:
    npm install --unsafe-perm -g node-sass
  • Manually installing node-gyp with this command:
    npm install node-gyp -g

If anyone has any experience or suggestions with this error I would really appreciate it.  Thanks!!

  • UPDATE:

    I was able to successfully install the lithium-sdk package.  First, I created a new "lithium" user on my server to run the npm commands, rather than running them as the root user. 

    Second, with the help of Khoros Support I realized that the syntax error I was getting was because npm was expecting to find Python 2.7 associated with /usr/bin/python, but on newer RHEL/CentOS/Rocky systems it looks like Python2 is not installed by default nor is it available via yum or dnf.

    Therefore, I had to manually download, compile, and install Python2 with the following commands:

    cd ~
    dnf -y groupinstall "development tools"
    curl -L -O https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz
    tar xf Python-2.7.18.tar.xz
    cd Python-2.7.18
    ./configure --prefix=/usr/local --enable-shared --enable-unicode=ucs4
    make && make altinstall
    update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 1
    update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2

     

    I then had to manually configure the python command to be associated with Python2.7 with this command:

    update-alternatives --config python

     

    As mentioned, this allowed me to successfully install the lithium-sdk package for the lithium user I created.

    However, for some reason even though it is installed successfully, the "li" command will not work and I get the following message when I try to use it:

    [lithium@new-server ~]$ li
    bash: li: command not found


    Does anyone know what I need to do to get the command to work now?

    Thanks in advance!

  • UPDATE:

    I was able to successfully install the lithium-sdk package.  First, I created a new "lithium" user on my server to run the npm commands, rather than running them as the root user. 

    Second, with the help of Khoros Support I realized that the syntax error I was getting was because npm was expecting to find Python 2.7 associated with /usr/bin/python, but on newer RHEL/CentOS/Rocky systems it looks like Python2 is not installed by default nor is it available via yum or dnf.

    Therefore, I had to manually download, compile, and install Python2 with the following commands:

    cd ~
    dnf -y groupinstall "development tools"
    curl -L -O https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz
    tar xf Python-2.7.18.tar.xz
    cd Python-2.7.18
    ./configure --prefix=/usr/local --enable-shared --enable-unicode=ucs4
    make && make altinstall
    update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 1
    update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2

     

    I then had to manually configure the python command to be associated with Python2.7 with this command:

    update-alternatives --config python

     

    As mentioned, this allowed me to successfully install the lithium-sdk package for the lithium user I created.

    However, for some reason even though it is installed successfully, the "li" command will not work and I get the following message when I try to use it:

    [lithium@new-server ~]$ li
    bash: li: command not found


    Does anyone know what I need to do to get the command to work now?

    Thanks in advance!

    • jeffshurtliff's avatar
      jeffshurtliff
      Boss

      UPDATE:

      I'm not entirely sure what changed, but I was able to re-run the command "npm install lithium-sdk -g" successfully (originally I was getting a permissions error but running the command with sudo kept trying to use python3 and was therefore failing) and now the "li" command is working as expected. 

      So it looks like everything is working now.

      Thanks for the help, everyone!

      • Parshant's avatar
        Parshant
        Boss

        jeffshurtliff, This issue is something different and coming for something for python executing while running node npm commands.

        I did install it previously on my linux and ubuntu system and it was working fine during that time.

  • UPDATE: 

    I switched to node v6.11.2 (as referenced in the documentation) and tried to install, but now I am getting this error when running the npm install -g lithium-sdk command:

     

    /root/.nvm/versions/node/v6.11.2/bin/li -> /root/.nvm/versions/node/v6.11.2/lib/node_modules/lithium-sdk/bin/li.js
    
    > node-sass@3.13.1 install /root/.nvm/versions/node/v6.11.2/lib/node_modules/lithium-sdk/node_modules/node-sass
    > node scripts/install.js
    
    module.js:491
        throw err;
        ^
    
    Error: Cannot find module '/root/.nvm/versions/node/v6.11.2/lib/node_modules/lithium-sdk/node_modules/node-sass/scripts/install.js'
        at Function.Module._resolveFilename (module.js:489:15)
        at Function.Module._load (module.js:439:25)
        at Function.Module.runMain (module.js:609:10)
        at startup (bootstrap_node.js:158:16)
        at bootstrap_node.js:578:3
    /root/.nvm/versions/node/v6.11.2/lib
    ā””ā”€ā”€ (empty)

     

     

    When I try to install node-sass manually with the npm install --unsafe-perm -g node-sass command I get the following error:

     

    [root@ip-10-185-75-24 ~]# npm install --unsafe-perm -g node-sass
    npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
    npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
    /root/.nvm/versions/node/v6.11.2/lib
    ā””ā”€ā”€ (empty)
    
    npm ERR! Linux 5.14.0-284.11.1.el9_2.x86_64
    npm ERR! argv "/root/.nvm/versions/node/v6.11.2/bin/node" "/root/.nvm/versions/node/v6.11.2/bin/npm" "install" "--unsafe-perm" "-g" "node-sass"
    npm ERR! node v6.11.2
    npm ERR! npm  v3.10.10
    npm ERR! path /root/.nvm/versions/node/v6.11.2/lib/node_modules/.staging/@types/normalize-package-data-b9438f12/package.json
    npm ERR! code ENOTDIR
    npm ERR! errno -20
    npm ERR! syscall open
    
    npm ERR! ENOTDIR: not a directory, open '/root/.nvm/versions/node/v6.11.2/lib/node_modules/.staging/@types/normalize-package-data-b9438f12/package.json'
    npm ERR!
    npm ERR! If you need help, you may report this error at:
    npm ERR!     <https://github.com/npm/npm/issues>
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     /root/npm-debug.log
    npm ERR! code 1
    [root@ip-10-185-75-24 ~]# ^C
    [root@ip-10-185-75-24 ~]# node uninstall node-sass
    module.js:471
        throw err;
        ^
    
    Error: Cannot find module '/root/uninstall'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.runMain (module.js:604:10)
        at run (bootstrap_node.js:389:7)
        at startup (bootstrap_node.js:149:9)
        at bootstrap_node.js:504:3

     

     

    I've opened a support case for this to see if Khoros Support can assist.