I thought it was the same thing as well but unfortunately when I use require('fs/promises') I do receive an error message on my node environment but not if I use the second option.
Error: Cannot find module 'fs/promises'
Require stack:
My node version is v12.18.3
_Originally posted by @muzhaqi16 in https://github.com/nodejs/node/pull/35726#issuecomment-713544608_
The current documentation is only true for Node.js 14+. For Node.js 12, please check out https://nodejs.org/docs/latest-v12.x/api/fs.html#fs_fs_promises_api
For info, here is the support table for those features:
| Node.js version range | require('fs/promises') | require('fs').promises |
| - | - | - |
| v10.0.0 | ✅ | ❌ |
| ≥v10.1.0 <14.0.0 | ❌ | ✅ |
| ≥14.0.0 | ✅ | ✅ |
Maybe we could add an history section in the docs to clarify what support users can expect.
Most helpful comment
The current documentation is only true for Node.js 14+. For Node.js 12, please check out https://nodejs.org/docs/latest-v12.x/api/fs.html#fs_fs_promises_api
For info, here is the support table for those features:
| Node.js version range |
require('fs/promises')|require('fs').promises|| - | - | - |
| v10.0.0 | ✅ | ❌ |
| ≥v10.1.0 <14.0.0 | ❌ | ✅ |
| ≥14.0.0 | ✅ | ✅ |
Maybe we could add an history section in the docs to clarify what support users can expect.