Mainostoimisto-Seven-1 / printify-nodejs

An API Wrapper written in TypeScript for the Printify Dropshipping API
https://npmjs.com/package/printify-nodejs
8 stars 1 forks source link

Dependency "crypto" not working #23

Closed Laurenz-M closed 1 year ago

Laurenz-M commented 1 year ago

Hey everyone! I have just installed your package via npm but I am getting an error regarding the "crypto" package that this project depends on. The error is as follows:

Failed to resolve entry for package "crypto". The package may have incorrect main/module/exports specified in its package.json.

image

I am using the newest version of vite for my project. I am happy to provide further information if neccessary.

I suspect that this issue comes from the "crypto" package, that wa discontinued and integrated directly into nodejs as opposed to being a standalone npm package.

Cheers, Laurenz

Laurenz-M commented 1 year ago

Edit: I have just removed all import references of "crypto" from the node_modules folder of the installed "printify-nodejs" package and vite started without error. Instead of explicitly importing crypto, it it now referenced globally.

//node_modules/printify-nodejs/dist/index.js

image

(Removed the import and referenced "crypto" like a global class)

//node_modules/printify-nodejs/dist/index.mjs

image

(Also removed the import)

This removes all my error right now, but i am unsure if everything still works as expected. Maybe you could look into my solution :)

Cheers, Laurenz

visitlo-old commented 1 year ago

Hi, thank you for bringing this up. I will push an update soon which will remove the crypto dependency from npm.

visitlo-old commented 1 year ago

Removing the crypto npm dependency in pr #24 It now imports the crypto package built into Node. And just to be clear, this api wrapper isn't meant to be used in the browser.

Don't hesitate to open another issue or re-open this one if there's something unclear still.