microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.42k stars 233 forks source link

Unable to install and run node-pty on SUSE/SLE15 (node version 18.8.2) #641

Closed maheshiv closed 6 months ago

maheshiv commented 7 months ago

Environment details

Issue description

I am trying to install node-pty on SUSE/SLE15 but it is throwing below error.

I am installing below packages git-core=2.35.3 nodejs18 npm18 python3 gcc-c++ make. Please guide me, if there is anything I need to do.

3.779 npm notice
3.779 npm notice New major version of npm available! 9.8.1 -> 10.2.4
3.779 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.4>
3.779 npm notice Run `npm install -g npm@10.2.4` to update!
3.779 npm notice
3.781 npm ERR! code 1
3.781 npm ERR! path /project/node_modules/node-pty
3.783 npm ERR! command failed
3.783 npm ERR! command sh -c node-gyp rebuild
3.784 npm ERR! gyp info it worked if it ends with ok
3.784 npm ERR! gyp info using node-gyp@9.4.0
3.784 npm ERR! gyp info using node@18.18.2 | linux | x64
3.784 npm ERR! gyp info find Python using Python version 3.6.15 found at "/usr/bin/python3"
3.784 npm ERR! gyp info spawn /usr/bin/python3
3.784 npm ERR! gyp info spawn args [
3.784 npm ERR! gyp info spawn args   '/usr/lib64/node_modules/npm18/node_modules/node-gyp/gyp/gyp_main.py',
3.784 npm ERR! gyp info spawn args   'binding.gyp',
3.784 npm ERR! gyp info spawn args   '-f',
3.784 npm ERR! gyp info spawn args   'make',
3.784 npm ERR! gyp info spawn args   '-I',
3.784 npm ERR! gyp info spawn args   '/project/node_modules/node-pty/build/config.gypi',
3.785 npm ERR! gyp info spawn args   '-I',
3.785 npm ERR! gyp info spawn args   '/usr/lib64/node_modules/npm18/node_modules/node-gyp/addon-rpm.gypi',
3.785 npm ERR! gyp info spawn args   '-I',
3.785 npm ERR! gyp info spawn args   '/usr/include/node18/common.gypi',
3.785 npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
3.785 npm ERR! gyp info spawn args   '-Dvisibility=default',
3.785 npm ERR! gyp info spawn args   '-Dnode_root_dir=/usr/include/node18',
3.785 npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib64/node_modules/npm18/node_modules/node-gyp',
3.785 npm ERR! gyp info spawn args   '-Dnode_lib_file=/usr/include/node18/<(target_arch)/node.lib',
3.785 npm ERR! gyp info spawn args   '-Dmodule_root_dir=/project/node_modules/node-pty',
3.785 npm ERR! gyp info spawn args   '-Dnode_engine=v8',
3.786 npm ERR! gyp info spawn args   '--depth=.',
3.786 npm ERR! gyp info spawn args   '--no-parallel',
3.786 npm ERR! gyp info spawn args   '--generator-output',
3.786 npm ERR! gyp info spawn args   'build',
3.786 npm ERR! gyp info spawn args   '-Goutput_dir=.'
3.786 npm ERR! gyp info spawn args ]
3.786 npm ERR! gyp: /usr/include/node18/common.gypi not found (cwd: /project/node_modules/node-pty) while reading includes of binding.gyp while trying to load binding.gyp
3.786 npm ERR! gyp ERR! configure error
3.786 npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
3.786 npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib64/node_modules/npm18/node_modules/node-gyp/lib/configure.js:329:16)
3.786 npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
3.786 npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
3.786 npm ERR! gyp ERR! System Linux 5.10.102.1-microsoft-standard-WSL2
3.786 npm ERR! gyp ERR! command "/usr/bin/node18" "/usr/lib64/node_modules/npm18/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
3.787 npm ERR! gyp ERR! cwd /project/node_modules/node-pty
3.787 npm ERR! gyp ERR! node -v v18.18.2
3.787 npm ERR! gyp ERR! node-gyp -v v9.4.0
3.787 npm ERR! gyp ERR! not ok

I tried another approach to install node-pty on node:18.18.2 image and then copy installed modules to SUSE/SLE15 image (which contains the node version 18.18.2) but it failed when running the node server. But this approach works if I use node version 16.20 on SUSE/SLE15.

innerError Error: Cannot find module '../build/Debug/pty.node'
Require stack:
- /project/node_modules/node-pty/lib/unixTerminal.js
- /project/node_modules/node-pty/lib/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/project/node_modules/node-pty/lib/unixTerminal.js:34:15)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/project/node_modules/node-pty/lib/unixTerminal.js',
    '/project/node_modules/node-pty/lib/index.js'
  ]
}
node:internal/modules/cjs/loader:1340
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /project/node_modules/node-pty/build/Release/pty.node)
    at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/project/node_modules/node-pty/lib/unixTerminal.js:29:11)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v18.18.2
Et7f3 commented 6 months ago

It seem you have an too old libc (or you are not using glibc) try to upgread to at least glibc2.34. It should get backward compatible. Another option (less easy) is to build the prebuilt binary yourself so you will get the same glibc.

maheshiv commented 6 months ago

Thanks @Et7f3 for the suggestion. But I solved the issue by upgrading the npm version (npm i npm@latest -g) using the first approach I mentioned on the question i.e., installed development package dependencies like python3, gcc-c++, make, and did not copied the installed modules from node:18.18.2 to SLES.