0
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

Kara
  • 6,115
  • 16
  • 50
  • 57
Demotivated
  • 117
  • 3
  • 13

2 Answers2

0

Your code should work.

Make sure the dependencies are installed

npm install

Make sure there is an index.js file in the root directory otherwise, update the start script to point to your main js file

Start your application using npm start

German Attanasio
  • 22,217
  • 7
  • 47
  • 63
0

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

Demotivated
  • 117
  • 3
  • 13