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.

node: CJS loader shouldn't require full read access.

See original GitHub issue

Currently, trying to use CJS loader you get following error:

error: Uncaught Error: CJS loader requires --allow-read.
      throw new Error("CJS loader requires --allow-read.");
            ^

It’s not strictly required to have full disk read access, the loader should work perfectly fine with access to the current directory.

CC @kt3k

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bartlomiejucommented, Nov 10, 2021

Discussed this offline with @ry, jumping to adding sync permissions API is not a good idea. We should change the error message in such a way that doesn’t suggest completely opening the sandbox for read operation, so maybe something like:

CJS loader requires read permissions. If packages are installed locally try passing --allow-read=node_modules/ flag.

Alternatively we could completely skip mapping an error to a new one and just return the default error message.

0reactions
bartlomiejucommented, Nov 10, 2021

I just tried to see if this solution is feasible and there’s a hiccup. APIs that are stating file system are all synchronous, while Deno.permission.request is an async API. There’s not much room for work arounds here as the APIs are ported from Node (eg. Module._findPath). Without synchronous permissions API we might not be able to handle that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loader Hooks · Issue #351 · nodejs/modules - GitHub
I think a node loader hook api needs to provide mechanisms for compounding on and falling back to already registered hooks (or the...
Read more >
Top 10 Most Common Node.js Developer Mistakes - Toptal
In this article, we will take a look at ten common mistakes that developers new to Node.js often make, and how they can...
Read more >
How the module system, CommonJS & require works
Learn how the Node.js module system & CommonJS works and what does `require` do under the hood.
Read more >
15 Common Error Codes in Node.js and How to Fix Them
Essentially, this error indicates that the user executing the script does not have the required permission to access a resource. A quick fix...
Read more >
Error: EACCES: permission denied - node.js - Stack Overflow
I know it is permission issue but as far as I know, sudo permission is not required for installing node module locally. If...
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