tejitak / node-cloud-vision-api

Node client for Google Cloud Vision API
112 stars 14 forks source link

client modules not found. #4

Closed averybross closed 8 years ago

averybross commented 8 years ago

I am getting the errors: Uncaught Error: Cannot find module './lib/clients/v1' and Uncaught Error: Cannot find module './lib/clients/v1alpha1' when trying to require in each of the different branches.

The errors are coming from the following line in node-cloud-vision-app/index.js: const Endpoint = require('./lib/clients/' + options.version)

Here is what my file looks like:

'use strict'
const vision = require('node-cloud-vision-api')

// init with auth
vision.init({auth: 'XXXXXXXXXXXXXXXXXXXX'})

// construct parameters
const req = new vision.Request({
  image: new vision.Image('/Users/richardbross/Downloads/card.jpg'),
  features: [
    new vision.Feature('FACE_DETECTION', 4),
    new vision.Feature('LABEL_DETECTION', 10),
  ]
})

// send single request
vision.annotate(req).then((res) => {
  // handling response
  console.log(JSON.stringify(res.responses))
}, (e) => {
  console.log('Error: ', e)
})
tejitak commented 8 years ago

Hi @RickBross , I think this issue is related to new release of cloud vision API.

The new version 'v0.2.0' of this module handles correctly thanks to #1 . Please try to remove node_modules and run 'npm install node-cloud-vision-api --save' again.

Thanks!

averybross commented 8 years ago

I did that, I am still getting Uncaught Error: Cannot find module './lib/clients/v1'

averybross commented 8 years ago

How do you suggest transpiling this into vanilla JS? Also, how do you suggest requiring in this module? I am using gulp right now with browserify and babelify...

Do you have a sample project where you have this working?

Cheers, Rick

averybross commented 8 years ago

Fix: use import * as vision from 'node-cloud-vision-api';

instead of const vision = require('node-cloud-vision-api')