Watson Assistant v2 Ionic-找不到模块:无法解析“ fs”

时间:2019-06-08 02:34:06

标签: typescript ionic4 watson-assistant

有了android studio中的Assistant java API版本,我有了很好的经验,它可以正常工作。

我的环境:

  • 离子CLI:5.0.1

  • 离子框架:@ ionic / angular 4.4.2

  • @ angular-devkit / build-angular:0.13.9
  • @ angular-devkit / schematics:7.3.9
  • @ angular / cli:7.3.9
  • @ ionic / angular-toolkit:1.5.1

现在,我正在使用ionic4尝试使用Assistant V2 API(节点版本:https://cloud.ibm.com/apidocs/assistant-v2?code=node)将请求发送到Watson Assistant,并且发现错误:

[ng] ERROR in ./node_modules/dotenv/lib/main.js
[ng] Module not found: Error: Can't resolve 'fs' in 'C:\Path\Chatbot\node_modules\dotenv\lib'
[ng] ERROR in ./node_modules/ibm-cloud-sdk-core/lib/read-credentials-file.js

home.page.ts

import { Component } from '@angular/core';

//const AssistantV2 = require('ibm-watson/assistant/v2');
import * as AssistantV2 from 'ibm-watson/assistant/v2'; 

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})

export class HomePage {
assistant: AssistantV2;
api_key;
url;
assistant_id;

constructor() { 
    this.api_key = '{my_apikey}'
    this.url = 'https://gateway.watsonplatform.net/assistant/api'
    this.version = '2019-02-28';
    this.assistant_id = "{my_assistantid}";

    this.assistant = new AssistantV2({
    iam_apikey: this.api_key,
    version: '2019-02-28',
    url: this.url
});

0 个答案:

没有答案