我正在尝试在我的 React 代码中使用https://github.com/theophilusx/ssh2-sftp-client 。 我得到了Uncaught TypeError: __webpack_require__(...).constants is undefined at const ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我有这个简单的 React 组件来处理 Active Directory 身份验证:
import React from 'react';
import ActiveDirectory from 'activedirectory';
export default class ActiveDirectoryComponent extends React.Component {
state = {
authResponse: undefined
};
componentDidMount() {
var config = {
url: 'ldap://compandomain.com:389',
baseDN: 'dc=domainname,dc=com',
username: 'user',
password: 'pass'
};
var ad = new ActiveDirectory(config);
var username = 'john.smith@domain.com';
var password = 'password';
ad.authenticate(username, password, function (err, auth) {
if (err) {
this.setState({ authResponse: { error: JSON.stringify(err) } });
return;
}
if (auth) {
this.setState({ authResponse: auth });
} else {
console.log('Authentication failed!');
this.setState({ authResponse: { authFailed: true } });
}
});
}
render() {
if (!this.state.authResponse) {
return <div>Authenticating....</div>;
}
if (this.state.authResponse.error) {
return <div>{this.state.authResponse.error}</div>
}
if (this.state.authResponse.authFailed) {
return <div>Authentication Failed</div>
}
return <div>.....</div>
}
}
当我尝试使用此组件时:
import ActiveDirectoryComponent from '../components/ActiveDirectoryAuthentication';
我的应用程序没有加载,我在控制台中收到此错误:
Uncaught TypeError: unknown stream type "undefined"
at Logger.addStream (bunyan.js?a10b:620)
at eval (bunyan.js?a10b:470)
at Array.forEach (<anonymous>)
at new Logger (bunyan.js?a10b:469)
at Function.createLogger (bunyan.js?a10b:1618)
at Object.eval (activedirectory.js?f995:16)
at eval (990:1836)
at Object.<anonymous> (bundle.js:1)
at e (bundle.js:1)
at eval (index.js?048a:1)
知道需要为 bunyan 设置什么才能正确地拥有流吗? 在我看来,这像是“activedirectory”模块中的一个问题,因为我认为它应该通过 bunyan 正确创建流。 但我并不完全确定,因为我对 React 非常陌生。
更新 (10/31/2018):'activedirectory' 模块在 Javascript 中完美运行。 上面的问题只在 React 中看到。 我必须编写一个单独的 Javascript 应用程序来与 activedirectory 交互并在我的 React 应用程序中使用它。 虽然这可以作为一种解决方法,但如果上述问题得到解决以便所有代码都在 React 中,那就太好了。
Github 上的 activedirectory 模块有一个开放的拉取请求,它解决了这个问题: https : //github.com/gheeres/node-activedirectory/pull/150/files
我在本地尝试过,它解决了问题。 希望 PR 最终会合并。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.