node: CJS loader shouldn't require full read access.
See original GitHub issueCurrently, 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:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
Alternatively we could completely skip mapping an error to a new one and just return the default error message.
I just tried to see if this solution is feasible and there’s a hiccup. APIs that are
stat
ing file system are all synchronous, whileDeno.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.