导入npm的ssh2模块后报错
Errors after importing ssh2 module of npm
我的任务是将 ssh 连接到集群并执行 spark 代码。这必须从浏览器完成。我正在使用 Reactjs 从 NPM 构建 UI 和 'ssh2' 以访问集群。当我使用下面的代码时。
var Client = require('ssh2').Client;
我收到以下警告和错误消息。
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.
我尝试通过添加
来更改 webpack.config.js 文件
target: 'node'
和
node: {
console: false,
fs: 'empty',
net: 'empty',
tls: 'empty'
},
问题依旧。我该如何解决这个问题?还有其他方法可以通过 ssh 进入集群吗?
我试图从 Web 浏览器通过 ssh 进入集群,该浏览器不支持或没有执行所需任务所需的协议。所以,最好在后端做。
我的任务是将 ssh 连接到集群并执行 spark 代码。这必须从浏览器完成。我正在使用 Reactjs 从 NPM 构建 UI 和 'ssh2' 以访问集群。当我使用下面的代码时。
var Client = require('ssh2').Client;
我收到以下警告和错误消息。
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.
我尝试通过添加
来更改 webpack.config.js 文件target: 'node'
和
node: {
console: false,
fs: 'empty',
net: 'empty',
tls: 'empty'
},
问题依旧。我该如何解决这个问题?还有其他方法可以通过 ssh 进入集群吗?
我试图从 Web 浏览器通过 ssh 进入集群,该浏览器不支持或没有执行所需任务所需的协议。所以,最好在后端做。