question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ERROR] Could not resolve "fs/promises"

See original GitHub issue

What version of Remix are you using?

Remix - Cloudflare workers @ latest

Steps to Reproduce

Hello, i’m trying to learn react and remix altogheter, I came across an error, trying to pass a multipart form from frontend to backend via form and action. As i try to import unstable_createMemoryUploadHandler it throws an error related to FS/Promises

17 │ var promises = require('fs/promises'); 

The package "fs/promises" wasn't found on the file system but is built into node. 
Are you trying to bundle for node? 
You can use "platform: 'node'" to do that, which will remove this error.


Build failed with 1 error:
node_modules/@remix-run/node/upload/fileUploadHandler.js:17:23: ERROR: Could not resolve "fs/promises"

So basically I don’t understand if I’m doing something wrong. As I could understand on cloudflare workers I have to rely on their services, and so no storage and so no fileUpload, i’m trying to use the stream to get the file posted with the request to pass it to supabase via service role key.

Any idea what am I missing?

Expected Behavior

Should create a uploaderHandle to pass to

export const action: ActionFunction = async ({
  request,
}) => {
  const uploadHandler = unstable_createMemoryUploadHandler({
    maxFileSize: 500_000,
  });
  const formData = await unstable_parseMultipartFormData(
    request,
    uploadHandler
  );

  const file = formData.get("avatar");

  // file is a "File" (https://mdn.io/File) polyfilled for node
  // ... etc

Actual Behavior

17 │ var promises = require('fs/promises'); 

The package "fs/promises" wasn't found on the file system but is built into node. 
Are you trying to bundle for node? 
You can use "platform: 'node'" to do that, which will remove this error.


Build failed with 1 error:
node_modules/@remix-run/node/upload/fileUploadHandler.js:17:23: ERROR: Could not resolve "fs/promises"

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:13
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mxp-qkcommented, Nov 26, 2022

Same issu for me, in my case this is due to importing anything (redirect, json) from @remix-run/node in a yarn PNP monorepo. I didn’t find a way around it but to use new Response (...)

2reactions
mcmxcdevcommented, Jun 21, 2022

Works for me with the adjustments I mentioned above @mcmxcdev +1

Thank you Tim, but we already use the new imports rather than the deprecated ones. We also don’t use fs-extra, so no clue where to start.

One way to solve this would be to patch away the line failing the CI run with https://www.npmjs.com/package/patch-package I guess.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't resolve 'fs/promises' · Issue #1612 - GitHub
running tsc compiles the files without any problem, but with webpack I got the error. Module not found: Error: Can't resolve 'fs/promises'.
Read more >
Module not found: Error: Can't resolve 'fs' in - Stack Overflow
I found a possible solution, that you have to put some configuration in one of the node_modules. But I think that is not...
Read more >
How to solve Cannot find module 'fs/promises'? - Medium
Recently, I need to install npm package name of rotating-file-stream. So, install it and start npm run… npm show error like below: Cannot...
Read more >
Error in set up of "fs-extra" module - Plugins - Joplin Forum
and this one is throughing error something like this is coming on terminal - ERROR in ./dist/index.js Module not found: Error: Can't resolve...
Read more >
How To Solve Module Not Found Can't Resolve 'fs' in Next.js
The Module not found: Can't resolve 'fs' error and similar issues most likely occur when you try to import a module that is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found