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

Error while importing WooCommerceRestApi in js file #115

Open
kmorte opened this issue Feb 13, 2022 · 5 comments
Open

Error while importing WooCommerceRestApi in js file #115

kmorte opened this issue Feb 13, 2022 · 5 comments

Comments

@kmorte
Copy link

kmorte commented Feb 13, 2022

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
Copy link

Same issue here

@kmorte
Copy link
Author

kmorte commented Feb 16, 2022

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
Copy link

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:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
resolve 'stream' in '********node_modules\cipher-base'
Parsed request is a module
using description file: ********node_modules\cipher-base\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
********node_modules\cipher-base\node_modules doesn't exist or is not a directory
********node_modules\node_modules doesn't exist or is not a directory
looking for modules in ********node_modules
single file module
using description file: ********package.json (relative path: ./node_modules/stream)
no extension
Field 'browser' doesn't contain a valid alias configuration
********node_modules\stream doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
********node_modules\stream.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
********node_modules\stream.tsx doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
********node_modules\stream.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
********node_modules\stream.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
********node_modules\stream.wasm doesn't exist
********node_modules\stream doesn't exist
********\node_modules doesn't exist or is not a directory
********\Siti e progetti\node_modules doesn't exist or is not a directory
********\node_modules doesn't exist or is not a directory
********node_modules doesn't exist or is not a directory
C:\Users\node_modules doesn't exist or is not a directory
C:\node_modules doesn't exist or is not a directory
@ ./node_modules/create-hmac/browser.js 4:11-33
@ ./node_modules/@woocommerce/woocommerce-rest-api/index.js 10:41-63
@ ./src/index.js 10:0-67 46:26-44

@blift
Copy link

blift commented Jul 6, 2022

Same issue, did you found some solution?

@blift
Copy link

blift commented Jul 14, 2022

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": {},
  },

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

No branches or pull requests

4 participants