percy / cli

The Percy CLI is used to interact with, and upload snapshots to, percy.io via the command line.
https://docs.percy.io/docs/cli-overview
71 stars 45 forks source link

TypeError: PercyClient is not a constructor #403

Closed holdenhinkle closed 3 years ago

holdenhinkle commented 3 years ago

I'm getting the following error:

const client = new PercyClient(options);
                 ^

TypeError: PercyClient is not a constructor

When I run:

const PercyClient = require('@percy/client');

function run() {
  const client = new PercyClient();
};

run();

Please advise. Thank you!

Robdel12 commented 3 years ago

Hey @holdenhinkle! Curious what you're looking to use such a low level package for. 👀

For the issue, you'll probably have to default on the require:

const PercyClient = require('@percy/client').default;

function run() {
  const client = new PercyClient();
};

run();
holdenhinkle commented 3 years ago

Thanks for your super fast response, Robert! That worked.

We want to monitor a couple of important pages in production. I'm trying to use Percy in an AWS CloudWatch Canary script.

Robdel12 commented 3 years ago

Gotcha! Are you looking to build your own SDK? @percy/client is pretty low level. You'll have to find, create, and manage your own builds & resources. You might be better off using @percy/core or one of our prebuilt SDKs

holdenhinkle commented 3 years ago

Yes, @percy/core is what I wanted. Thanks. I've got it working :-)

How can I get a read access token so I can query a build?

Robdel12 commented 3 years ago

You can get the full access token (read/write) from the link in the docs here: https://docs.percy.io/docs/cli-build#percy-buildwait

We'll soon be exposing these in a nice way in the UI. :D

holdenhinkle commented 3 years ago

Thanks Robert!

I didn't see that in the docs. I reached out to support and they responded quickly with that same link.

Thanks again :-)

Robdel12 commented 3 years ago

Awesome! Happy to hear -- I'll close this issue up 🎉