billchurch / webssh2

Web SSH Client using ssh2, socket.io, xterm.js, and express. webssh webssh2
MIT License
2.32k stars 530 forks source link

Webssh2 service fails to start on Node v10 #282

Closed ericrife closed 2 years ago

ericrife commented 2 years ago

With the latest socket.js update webssh2 fails to start.

npm start

webssh2@0.4.6 start /opt/webssh2/app node index.js

WebSSH2 service reading config from: /opt/webssh2/app/config.json /opt/webssh2/app/server/socket.js:103 if (socket.request.session?.ssh?.allowedSubnets?.length > 0) { ^

SyntaxError: Unexpected token . at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/opt/webssh2/app/server/app.js:31:19) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! webssh2@0.4.6 start: node index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the webssh2@0.4.6 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-05-16T20_16_13_959Z-debug.log

more /root/.npm/_logs/2022-05-16T20_16_13_959Z-debug.log 0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm@6.14.4 3 info using node@v10.19.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle webssh2@0.4.6~prestart: webssh2@0.4.6 6 info lifecycle webssh2@0.4.6~start: webssh2@0.4.6 7 verbose lifecycle webssh2@0.4.6~start: unsafe-perm in lifecycle true 8 verbose lifecycle webssh2@0.4.6~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/opt/webssh2/app/node_modules/.bin:/u sr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 9 verbose lifecycle webssh2@0.4.6~start: CWD: /opt/webssh2/app 10 silly lifecycle webssh2@0.4.6~start: Args: [ '-c', 'node index.js' ] 11 silly lifecycle webssh2@0.4.6~start: Returned: code: 1 signal: null 12 info lifecycle webssh2@0.4.6~start: Failed to exec start script 13 verbose stack Error: webssh2@0.4.6 start: node index.js 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:198:13) 13 verbose stack at ChildProcess. (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:198:13) 13 verbose stack at maybeClose (internal/child_process.js:982:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid webssh2@0.4.6 15 verbose cwd /opt/webssh2/app 16 verbose Linux 5.13.0-28-generic 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v10.19.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 1 22 error webssh2@0.4.6 start: node index.js 22 error Exit status 1 23 error Failed at the webssh2@0.4.6 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

CONFIG.JSON config.json { "listen": { "ip": "x.x.x.x", "port": 2222 }, "http": { "origins": ["x.x.x.x:2222"] }, "user": { "name": "", "password": "", "privatekey": "-----BEGIN RSA PRIVATE KEY-----n-----END RSA PRIVATE KEY-----\n", "overridebasic": false }, "ssh": { "host": "x.x.x.x", "port": 22, "localAddress": null, "localPort": null, "term": "xterm-color", "readyTimeout": 20000, "keepaliveInterval": 120000, "keepaliveCountMax": 10, "allowedSubnets": [] }, "terminal": { "cursorBlink": true, "scrollback": 10000, "tabStopWidth": 8, "bellStyle": "sound" }, "header": { "text": null, "background": "green" }, "session": { "name": "", "secret": "" }, "options": { "challengeButton": true, "allowreauth": false }, "algorithms": { "kex": [ "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "diffie-hellman-group-exchange-sha256", "diffie-hellman-group14-sha1" ], "cipher": [ "aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm", "aes128-gcm@openssh.com", "aes256-gcm", "aes256-gcm@openssh.com", "aes256-cbc" ], "hmac": [ "hmac-sha2-256", "hmac-sha2-512", "hmac-sha1" ], "compress": [ "none", "zlib@openssh.com", "zlib" ] }, "serverlog": { "client": false, "server": false }, "accesslog": false, "verify": false, "safeShutdownDuration": 300 }

Was able to get this to work by checking out the previous commit hash 522278fa4eefe3928025cd88e0bb4100fbc477b7 and rerun npm install.

billchurch commented 2 years ago

First, thank you for opening an issue on this.

This is expected as this project is committed to supporting only Node v14+.

While previous releases may have worked fine, there's no guarantee that future releases won't break if run in something lower than Node 14.

Optional Chaining is something that was introduced in Node 14 and helps to make code easier to maintain. Right now I'm going through a re-factoring exercise so anything in main will probably be broken.

It's a good point though, a lot of times people just pull from main as opposed to the Releases which use tags to denote an individual, supported release.

I recommend you use v0.4.6. As it should mostly be compatible with node@v10.

I do recommend, however, that you upgrade to at least Node v14 LTS (EOL April 2023) and keep up to date, but preferably Node v16 LTS (EOL April 2024).