-1

I have a task of doing ssh into a cluster and execute spark code. This has to be done from the browser. I am using Reactjs to build UI and 'ssh2' from NPM to access the cluster. When I use the following code.

var Client = require('ssh2').Client;

I get the follwing warning and error message.

WARNING in ./node_modules/defaultable/defaultable.js
49:13-31 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/defaultable/defaultable.js
 @ ./node_modules/hbo-dnsd/server.js
 @ ./node_modules/hbo-dnsd/named.js
 @ ./node_modules/dns/lib/dns.js
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/ssh2/lib/agent.js
Module not found: Error: Can't resolve 'child_process' in '/Users/byra/Work/reactTest/node_modules/ssh2/lib'
 @ ./node_modules/ssh2/lib/agent.js 6:9-33
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/native-dns-cache/lookup.js
Module not found: Error: Can't resolve 'dgram' in '/Users/byra/Work/reactTest/node_modules/native-dns-cache'
 @ ./node_modules/native-dns-cache/lookup.js 21:12-28
 @ ./node_modules/native-dns-cache/index.js
 @ ./node_modules/native-dns/lib/platform.js
 @ ./node_modules/native-dns/dns.js
 @ ./node_modules/dns/lib/dns.js
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/native-dns/lib/server.js
Module not found: Error: Can't resolve 'dgram' in '/Users/byra/Work/reactTest/node_modules/native-dns/lib'
 @ ./node_modules/native-dns/lib/server.js 23:12-28
 @ ./node_modules/native-dns/dns.js
 @ ./node_modules/dns/lib/dns.js
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/native-dns/lib/utils.js
Module not found: Error: Can't resolve 'dgram' in '/Users/byra/Work/reactTest/node_modules/native-dns/lib'
 @ ./node_modules/native-dns/lib/utils.js 21:12-28
 @ ./node_modules/native-dns/lib/server.js
 @ ./node_modules/native-dns/dns.js
 @ ./node_modules/dns/lib/dns.js
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/native-dns/lib/platform.js
Module not found: Error: Can't resolve 'fs' in '/Users/byra/Work/reactTest/node_modules/native-dns/lib'
 @ ./node_modules/native-dns/lib/platform.js 23:9-22
 @ ./node_modules/native-dns/dns.js
 @ ./node_modules/dns/lib/dns.js
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '/Users/byra/Work/reactTest/node_modules/request/lib'
 @ ./node_modules/request/lib/har.js 3:9-22
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./node_modules/webhdfs/lib/webhdfs.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/ssh2-streams/lib/sftp.js
Module not found: Error: Can't resolve 'fs' in '/Users/byra/Work/reactTest/node_modules/ssh2-streams/lib'
 @ ./node_modules/ssh2-streams/lib/sftp.js 6:16-29 11:9-22
 @ ./node_modules/ssh2-streams/index.js
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/ssh2/lib/agent.js
Module not found: Error: Can't resolve 'fs' in '/Users/byra/Work/reactTest/node_modules/ssh2/lib'
 @ ./node_modules/ssh2/lib/agent.js 5:9-22
 @ ./node_modules/ssh2/lib/client.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/byra/Work/reactTest/node_modules/forever-agent'
 @ ./node_modules/forever-agent/index.js 7:10-24
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./node_modules/webhdfs/lib/webhdfs.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/byra/Work/reactTest/node_modules/tunnel-agent'
 @ ./node_modules/tunnel-agent/index.js 4:10-24
 @ ./node_modules/request/lib/tunnel.js
 @ ./node_modules/request/request.js
 @ ./node_modules/request/index.js
 @ ./node_modules/webhdfs/lib/webhdfs.js
 @ ./App.jsx
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./main.js
webpack: Failed to compile.

I tried changing webpack.config.js file by adding

target: 'node'

and

node: {
        console: false,
        fs: 'empty',
        net: 'empty',
        tls: 'empty'
    },

Still, the problem remains same. How do I fix this issue? Is there another way to ssh into a cluster?

1 Answers1

0

I was trying to ssh into the cluster from a Web Browser, which doesn't support or have required protocols do the required task. So, it is better to do on the backend.