Reactjs 导入npm的ssh2模块后出错
我的任务是在集群中执行ssh并执行spark代码。这必须从浏览器中完成。我正在使用Reactjs构建UI,并使用NPM中的“ssh2”访问集群。当我使用以下代码时Reactjs 导入npm的ssh2模块后出错,reactjs,ssh,npm,libssh2,Reactjs,Ssh,Npm,Libssh2,我的任务是在集群中执行ssh并执行spark代码。这必须从浏览器中完成。我正在使用Reactjs构建UI,并使用NPM中的“ssh2”访问集群。当我使用以下代码时 var-Client=require('ssh2')。客户端; 我收到以下警告和错误消息 WARNING in ./node_modules/defaultable/defaultable.js 49:13-31 Critical dependency: the request of a dependency is an expre
var-Client=require('ssh2')。客户端;
我收到以下警告和错误消息
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.
我试图通过添加
target: 'node'
及
尽管如此,问题依然存在。如何解决此问题?还有其他方法可以通过ssh连接到集群吗?我试图通过Web浏览器通过ssh连接到集群,但该浏览器不支持或不让所需的协议执行所需的任务。因此,最好在后端执行
node: {
console: false,
fs: 'empty',
net: 'empty',
tls: 'empty'
},