-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Closed
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.
Description
- Version: v10.2.1
- Platform: Windows 10 64-bit
- Subsystem: fs
Per the docs, “The API is accessible via require('fs').promises
.”
When using ECMAScript Modules it can’t be accessed like that. One may expect to be able to load it with import {promises as fs} from 'fs'
, but this gives an error.
import {promises as fs} from 'fs'
^^^^^^^^
SyntaxError: The requested module 'fs' does not provide an export named 'promises'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:89:21)
So right now accessing the fs Promises API directly when using ECMAScript Modules requires two lines, like so:
import {default as fsWithCallbacks} from 'fs'
const fs = fsWithCallbacks.promises
jacobg, Type1J, yukulele, mariocasciaro, shinout and 20 more
Metadata
Metadata
Assignees
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.fsIssues and PRs related to the fs subsystem / file system.Issues and PRs related to the fs subsystem / file system.