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.

[Bug?]: `fs/promises` is detected as a dependency

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

Any package which uses fs/promises is unable to import as yarn asks this to be listed in it’s dependencies.

Error: builder-util tried to access fs, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: fs (via "fs/promises")

To reproduce

await packageJsonAndInstall({});

await expect(node(`require.resolve('fs/promises')`)).resolves.toBeTruthy();

You can also go into any repo running yarn@3, make a file with require('fs/promises') and run yarn node file.js

Error: Your application tried to access fs, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: fs (via "fs/promises")

Environment

System: OS: Linux 4.15 Ubuntu 16.04.7 LTS (Xenial Xerus) CPU: (6) x64 AMD FX™-6100 Six-Core Processor Binaries: Node: 12.22.5 - /tmp/xfs-38ba3067/node Yarn: 3.0.1 - /tmp/xfs-38ba3067/yarn npm: 6.14.14 - ~/.nvm/versions/node/v12.22.5/bin/npm

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
merceyzcommented, Aug 28, 2021

Node 12.22.5 doesn’t report fs/promises as a builtin module

$ node -p "require('module').builtinModules" | grep fs
  'domain',            'events',              'fs',

I found this hard to reproduce in the sherlock shell, I’d always get

You were missing an install and a expect to assert what should happen, I’ve updated your repro but it wont reproduce as it runs with Node 14 which does report it as a builtin module

$ node -p "require('module').builtinModules" | grep fs
  'fs',                'fs/promises',         'http',
0reactions
yarnbotcommented, Aug 28, 2021

We couldn’t reproduce your issue (all the assertions passed on master).

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - fs/promises api in typescript not compiling in ...
I was recently working with typescript and fs/promises API and got this error when the typescript code was compiled and run, ...
Read more >
CJS loader error caught in PnP is different from expected ...
The issue manifests itself for external "type": "module" dependencies, e.g. node-fetch . For workspace dependencies the error is the same as ...
Read more >
Dependency injection | LoopBack Documentation
LoopBack can detect circular dependencies and report the path which leads to the problem. Consider the following example: import {Context, inject} from ...
Read more >
Changelog
Installing a dependency with the same name as the root project no longer requires --force . (That is, the ENOSELF error is removed.)...
Read more >
Node.js v19.3.0 Documentation
appendFile(path, data[, options]); fsPromises.chmod(path, mode) ... Error behavior; Integrity checks; Dependency redirection; Example: Patched dependency.
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