I'm trying to set up a visual recognition app using the Watson visual recognition api. To do this I started by downloading watson-developer-cloud and I put it in my node_modules folder, which is next to my index.html and api_request.js.
This is my api_request.js file:
var watson = require('./node_modules/watson-developer-cloud');
var visual_recognition = watson.visual_recognition({
username: '*********',
password: '*********',
version: 'v2-beta',
version_date: '2015-12-02'
});
visual_recognition.listClassifiers({},
function(err, response) {
if (err){
console.log(err);
}
else {
console.log(JSON.stringify(response, null, 2));
}
}
);
It is taken directly from the visual recognition api documentation. I ran this file in the terminal and it provided the desired output which is a list of visual recognition classifiers. However as it has node.js functions I decided to use browserify to allow it to run in the browser. I installed browserify and built bundle.js out of api_request.js in the same directory as the api_request.js and index.html file.
Once index.html was linked to bundle.js I opened it in the browser and it didn't have any issues with node.js functions.
However an error occurred when a file that was in watson-developer-cloud couldn't find another file that was inside watson-developer-cloud. To be specific index.js couldn't find v2-beta (I didn't edit the watson-developer-cloud files). What I find strange is that when I ran api_request.js in the terminal none of the watson-developer-cloud files had any problems, but once I used browserify, bundle.js logged the error that index.js couldn't find v2-beta.
"build": "browserify api_request.js -o bundle.js"
^that is the script I used to build bundle.js. The only thing I can think could be causing this error is browserify. Is there something else that could be causing this?