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: Cannot find module './fetch.node' #1183

Closed
Tracked by #1
Honour-d-dev opened this issue Nov 26, 2023 · 6 comments
Closed
Tracked by #1

Error: Cannot find module './fetch.node' #1183

Honour-d-dev opened this issue Nov 26, 2023 · 6 comments
Assignees

Comments

@Honour-d-dev
Copy link

Honour-d-dev commented Nov 26, 2023

i'm using w3up-client in a Next.js app on the server for delegating capabilities to the frontend users (i.e thats the delegation model from the docs i believe)

and i keep getting this error

Error: Cannot find module './fetch.node'
    at webpackEmptyContext (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\app\page.js:22:10)
    at __webpack_require__ (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\webpack-runtime.js:33:43)     
    at __webpack_require__ (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\webpack-runtime.js:33:43)     
    at __webpack_require__ (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\webpack-runtime.js:33:43)     
    at __webpack_require__ (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\webpack-runtime.js:33:43)     
    at __webpack_require__ (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\webpack-runtime.js:33:43)     
    at eval (./server/w3up-client.ts:11:83)
    at (action-browser)/./server/w3up-client.ts (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\app\page.js:705:1)
    at Function.__webpack_require__ (C:\Users\hp\VsCode\AYA-Project--Blockchain-EHR-System\frontend\.next\server\webpack-runtime.js:33:43)
### Tasks
@salieflewis
Copy link

I'm running into this error as well.

Unrelated, but are you using w3up inside server actions @Honour-d-dev?

Care to share any code?

@Honour-d-dev
Copy link
Author

I'm running into this error as well.

Unrelated, but are you using w3up inside server actions @Honour-d-dev?

Care to share any code?

Yeah , i am using it inside a server action and i finally got it working(my bad for not posting a solution)

i installed ipfs-utils then updated my next.config.js file with

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: ["ipfs-utils"],
  },
};

module.exports = nextConfig;

initially though i had to manually resolve the require statement in the ipfs-utils/src/fetch.js & ipfs-utils/src/http/fetch.js
with

module.exports = require('native-fetch')

&

module.exports = require('./fetch.node')

respectively , before finding the next.js configuration.
let me know if anyone works for you

@salieflewis
Copy link

Amazing, will try this out. Thank you.

@salieflewis
Copy link

salieflewis commented Dec 1, 2023

Also curious if you'd share how you're instantiating a client given most of the example code uses top-level awaits.

Here is what I've written so far.

https://gist.github.com/salieflewis/bbba37daba7acd0edff39ff32e32a72d

cc: @Honour-d-dev

@travis travis self-assigned this Dec 6, 2023
gobengo added a commit that referenced this issue Dec 13, 2023
because importing it in bundled setups breaks, e.g.
* #1183
* #828

I tested this change locally and confirmed that once it's made,
upload-client can be relied on by a nextjs project and build
successfully
@salieflewis
Copy link

This has been resolved in @web3-storage/w3up-client: 12.0.0

@Honour-d-dev

@travis travis closed this as completed Jan 3, 2024
@travis
Copy link
Member

travis commented Jan 3, 2024

huge thanks to @gobengo for digging into this!

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

3 participants