woocommerce / woocommerce-rest-api-js-lib

New JavaScript library for WooCommerce REST API
https://www.npmjs.com/package/@woocommerce/woocommerce-rest-api
MIT License
285 stars 75 forks source link

Error while importing WooCommerceRestApi in js file #115

Open kmorte opened 2 years ago

kmorte commented 2 years ago

Hi,

i just install the library with: npm i @woocommerce/woocommerce-rest-api

Then I imported the module as the specifications: import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api";

But there is a typeError:

image

Any idea?

Thank you very much!

juampick commented 2 years ago

Same issue here

kmorte commented 2 years ago

Where are you deploying the library? front or backend? In my case, I was trying to import it in frontend. I was about to remove the issue;

mredodos commented 2 years ago

more issue with wordpress/scripts

ERROR in ./node_modules/cipher-base/index.js 2:16-43 Module not found: Error: Can't resolve 'stream' in '****node_modules\cipher-base'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:

blift commented 2 years ago

Same issue, did you found some solution?

blift commented 2 years ago

Hey all,

Ok I've found some solution ( it works on my side with bud.js )

install stream and stream-browserify

    "stream": "^0.0.2",
    "stream-browserify": "^3.0.0"

and define global in your build tools

  define: {
    "global": {},
  },