ProjectOpenSea / opensea-js

TypeScript SDK for the OpenSea marketplace
https://docs.opensea.io/reference
MIT License
2.28k stars 955 forks source link

Next.js build Errors in 4.0.3 #604

Closed SMLaursen closed 1 year ago

SMLaursen commented 2 years ago

yarn 3.2.1 node 16.15.1 npm 8.11.0

After upgrading to opensea-js@4.0.3 from 4.0.1 In my Next.js project, I got the following build errors;

Failed` to compile.

../node_modules/opensea-js/lib/sdk.js
Module not found: Can't resolve 'wyvern-schemas' in 'C:\Users\sunela\workspace\nft-poc\node_modules\opensea-js\lib'

Import trace for requested module:
../node_modules/opensea-js/lib/index.js
./src/pages/buyopensea/[...query].tsx

../node_modules/opensea-js/lib/utils/schema.js
Module not found: Can't resolve 'wyvern-schemas/dist/types' in 'C:\Users\sunela\workspace\nft-poc\node_modules\opensea-js\lib\utils'

Import trace for requested module:
../node_modules/opensea-js/lib/index.js
./src/pages/buyopensea/[...query].tsx

../node_modules/opensea-js/lib/utils/schema.js
Module not found: Can't resolve 'wyvern-schemas' in 'C:\Users\sunela\workspace\nft-poc\node_modules\opensea-js\lib\utils'

Import trace for requested module:
../node_modules/opensea-js/lib/index.js
./src/pages/buyopensea/[...query].tsx

../node_modules/opensea-js/lib/utils/utils.js
Module not found: Can't resolve 'wyvern-schemas/dist/types' in 'C:\Users\sunela\workspace\nft-poc\node_modules\opensea-js\lib\utils'

Import trace for requested module:
./src/pages/buyopensea/[...query].tsx

> Build failed because of webpack errors
jtaaa commented 2 years ago

Hey @SMLaursen can you provide some details on your build process and webpack config?

SMLaursen commented 2 years ago

I realize this may be due to some Next.js configuration, and renamed the issue to reflect this.

My build process is simply just calling next build - not entirely sure what it entails but it have worked up until 4.0.3.

My webpack config is defined by NextConfig and due to #421, the addition of

  webpack: (config, {}) => {
    config.resolve.fallback = {
      ...config.resolve.fallback,
      fs: false,
    }
    return config
  },

Let me know if you need any other information

yarn 3.2.1 node 16.15.1 npm 8.11.0 next 12.0.8

vladopaets commented 2 years ago

Same issue on my project.

jtaaa commented 2 years ago

@SMLaursen thanks. I was able to reproduce. Adding this yarn resolution to your package.json should fix the issue:

  "resolutions": {
    "@0x/utils": "https://github.com/ProjectOpensea/0x-tools/raw/provider-patch/utils/0x-utils-6.5.0.tgz"
  }

Let me know if that works.

SMLaursen commented 2 years ago

Thanks for the quick reply, I was already using that workaround to avoid getting provider-related errors when validating wyvern orders.

Unfortunately this doesn't fix my build issues introduced with 4.0.3

danizord commented 2 years ago

@SMLaursen I was having the exact same error message and I fixed it with:

  "resolutions": {
    "wyvern-schemas": "github:ProjectOpenSea/wyvern-schemas#b829f3e93b0332f280f547875b31a9a3c7ae092a"
  }

I'm using yarn v3 and for some reason when installing wyvern-schemas using any commit after this one generates an empty "wyvern-schemas" package with only LICENSE, package.json files.

latest commit works fine in yarn v1, but I can't return to yarn v1 here.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.