Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to compile #25

Open
precious-akpan opened this issue Aug 3, 2021 · 5 comments
Open

Failed to compile #25

precious-akpan opened this issue Aug 3, 2021 · 5 comments

Comments

@precious-akpan
Copy link

Hi

After importing the clarifai-nodejs-grpc package, I get this error:

./node_modules/@grpc/grpc-js/build/src/server.js
Module not found: Can't resolve 'http2' in 'C:\Users\Nene\Desktop\WebWork\face-recognition-app\node_modules@grpc\grpc-js\build\src'

Thanks

@onestefcloser
Copy link

onestefcloser commented Jan 6, 2022

any solutions for this? I've tried installing missing packages manually through npm but same error ocurs

@precious-akpan
Copy link
Author

precious-akpan commented Feb 24, 2022

It seems it only affects Windows users.

I did the same as well but it didn't work either, so I used JavaScript repo and it worked.

@sayedulkrm
Copy link

Yeah bro same here.

But " JavaScript repo " they said not to use it and use the clarifai-nodejs-grpc.

@alexandros-megas
Copy link

Is this issue still occurring for folks? I'm able to successfully connect, authenticate and make a call with the following snippet (modified the README getting started code a bit to get it to work)

const {grpc} = require("clarifai-nodejs-grpc");
const service = require("clarifai-nodejs-grpc/proto/clarifai/api/service_pb");
const resources = require("clarifai-nodejs-grpc/proto/clarifai/api/resources_pb");
const {StatusCode} = require("clarifai-nodejs-grpc/proto/clarifai/api/status/status_code_pb");
const {V2Client} = require("clarifai-nodejs-grpc/proto/clarifai/api/service_grpc_pb");

const metadata = new grpc.Metadata();
metadata.set("authorization", "Key YOUR_KEY_HERE");

const clarifai = new V2Client("api.clarifai.com", grpc.ChannelCredentials.createSsl());

const request = new service.PostModelOutputsRequest();
request.setUserAppId(new resources.UserAppIDSet().setUserId("clarifai").setAppId("main"))
request.setModelId("general-image-recognition");
request.addInputs(
    new resources.Input()
        .setData(
            new resources.Data()
                .setImage(
                    new resources.Image()
                        .setUrl("https://samples.clarifai.com/dog2.jpeg")
                )
        )
)

clarifai.postModelOutputs(
  request,
  metadata,
  (err, response) => {
    if (err) {
        console.log("Error: " + err);
        return;
    }

    if (response.getStatus().getCode() !== StatusCode.SUCCESS) {
      throw "Error: " + response.getStatus();
    }

    console.log("Predicted concepts, with confidence values:")
    for (const concept of response.getOutputsList()[0].getData().getConceptsList()) {
        console.log(concept.getName() + " " + concept.getValue());
    }
  }
);

If this is still an issue, please provide more info, and I can try to reproduce.

For reference, I'm using node v16.13.1, I did npm init -y in an empty dir to create a new project, yarn add clarifai-nodejs-grpc to install this package, and created main.js with the above code which gives the following output:

Predicted concepts, with confidence values:
dog 0.9981174468994141
animal 0.9885246157646179
pet 0.984154462814331
cute 0.9807240962982178
portrait 0.9787907600402832
mammal 0.9730609059333801
fur 0.9716914296150208
canine 0.9650460481643677
puppy 0.9600763916969299
funny 0.9451291561126709
eye 0.9267837405204773
one 0.919833779335022
no person 0.9089270830154419
friendship 0.8976510167121887
sit 0.888274073600769
obedience 0.8839777708053589
looking 0.8775296807289124
little 0.8601778149604797
guard 0.8429452180862427
hair 0.8406715989112854

@ambmuna
Copy link

ambmuna commented Oct 5, 2022

Hi

I'm a window user and I'm having the same issue, may you please provide another solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants