Search code examples
node.jsibm-watsonpersonality-insights

Personality insight input var nodejs


var express = require('express');
var app = express();
var http = require('http').Server(app);
var cfenv = require("cfenv");

var appEnv = cfenv.getAppEnv();

http.listen(appEnv.port, appEnv.bind);

var PersonalityInsightsV2 = require('watson-developer-cloud/personality-insights/v2');

var personality_insights = new PersonalityInsightsV2({
  username: '<YOUR-USERNAME>',
  password: '<YOUR-PASSWORD>'
});

personality_insights.profile({
  text: "<YOUR-100-UNIQUE-WORDS>",
  language: 'en' },
  function (err, response) {
    if (err)
      console.log('error:', err);
    else
      console.log(JSON.stringify(response, null, 2));
});

I created these two files the above index.js and package.json

    {
  "name": "myWatsonApp",
  "version": "1.0.0",
  "description": "A Watson Personality Insights application",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "cfenv": "^1.0.3",
    "express": "^4.13.4",
    "watson-developer-cloud": "^2.2.0"
  }
}

when I run npm start I gives me this error enter image description here


Solution

  • I should include the files in my main system to the folder that I run.Thats how I solved it!