Manah Hamadeh
Manah Hamadeh

Reputation: 1

not able to run the code due to module ibm-watson/auth is cant fund

The below code snippet is from the watson tone analyzer documentation. The issue : when I paste the code and run the code it runs perfectly fine. However, when I paste it in another cloud function, it is stating that module of ibm-watson/auth cant be found. Not sure why it behaving differently ??

usually i save under the function main (params){}. However, the other cloud function is async function and it has the code for (require-promise). not sure what is wrong or what is the issue?

const ToneAnalyzerV3 = require('ibm-watson/tone-analyzer/v3');
const { IamAuthenticator } = require('ibm-watson/sdk');

const toneAnalyzer = new ToneAnalyzerV3({
  version: '2017-09-21',
  authenticator: new IamAuthenticator({
    apikey: 'apikey',
  }),
  serviceUrl: 'url',
});

const text = 'Team, I know that times are tough! Product '
  + 'sales have been disappointing for the past three '
  + 'quarters. We have a competitive product, but we '
  + 'need to do a better job of selling it!';

const toneParams = {
  toneInput: { 'text': text },
  contentType: 'application/json',
};

toneAnalyzer.tone(toneParams)
  .then(toneAnalysis => {
    console.log(JSON.stringify(toneAnalysis, null, 2));
  })
  .catch(err => {
    console.log('error:', err);
  });
    }

Upvotes: 0

Views: 138

Answers (1)

data_henrik
data_henrik

Reputation: 17176

When working with IBM Cloud Functions, be aware of the different runtime environments and their included modules and packages. If you run into an error that a certain module is not found, you

Upvotes: 0

Related Questions