-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Can’t import fs Promises API with ECMAScript Modules #21014
Copy link
Copy link
Closed
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
Description
Activity
Metadata
Metadata
Assignees
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.Issues and PRs related to file-system APIs and the fs module.
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.So right now accessing the fs Promises API directly when using ECMAScript Modules requires two lines, like so: