【问题标题】:OKTA API - TypeError: fs.existsSync is not a functionOKTA API - TypeError:fs.​​existsSync 不是函数
【发布时间】:2021-09-24 21:05:25
【问题描述】:

我正在使用下面的代码遵循link 中的 OKTA API 说明。但是,我遇到了错误

TypeError: fs.existsSync 不是函数

如何解决这个问题?我正在使用 nodejs v12。想知道是否有更新的说明。

const okta = require('@okta/okta-sdk-nodejs');
const client = new okta.Client({
  orgUrl: 'https://dev-1234.oktapreview.com/',
  token: 'xYzabc'    // Obtained from Developer Dashboard
});

这是完整的错误日志

applyDefaults
node_modules/@okta/okta-sdk-nodejs/src/config-loader.js:47

  44 | // Apply defaults defined in yaml
  45 | const localYamlPath = path.join(process.cwd(), 'okta.yaml');
  46 | const globalYamlPath = path.join(os.homedir(), '.okta', 'okta.yaml');
> 47 | if (fs.existsSync(globalYamlPath)) {
     | ^  48 |   this.applyYamlFile(globalYamlPath);
  49 | }
  50 | if (fs.existsSync(localYamlPath)) {

Client
node_modules/@okta/okta-sdk-nodejs/src/client.js:35

  32 | super();
  33 | const configLoader = new ConfigLoader();
  34 | const clientConfig = Object.assign({}, config);
> 35 | configLoader.applyDefaults();
     | ^  36 | configLoader.apply({
  37 |   client: clientConfig || {}
  38 | });

./src/App.js/<
src/App.js:6

  3 | 
  4 | const okta = require('@okta/okta-sdk-nodejs');
  5 | 
> 6 | const client = new okta.Client({

【问题讨论】:

    标签: node.js api okta


    【解决方案1】:

    上面的代码应该在服务器端使用。它被错误地放置在客户端导致错误。

    【讨论】:

      猜你喜欢
      • 2020-02-12
      • 1970-01-01
      • 2020-11-16
      • 2020-04-26
      • 2020-03-01
      • 2021-08-26
      • 2022-06-30
      • 2021-01-10
      • 2016-10-03
      相关资源
      最近更新 更多