Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs remove a file: TypeError: promises_1.rm is not a function

Tags:

node.js

The docs for removing a file say that it should be imported the same as readfile as far as I understand it.

am I missing something?

in my code I have:

import { readFile, rm } from 'fs/promises'

export async function foo () {
  try {
    const res = await readFile('./file.txt') // works
    await rm('./file.txt') // TypeError: promises_1.rm is not a function
  } catch(e) {
    console.log('er', e)
  }
}
like image 994
Ctfrancia Avatar asked Jun 24 '26 04:06

Ctfrancia


1 Answers

as @jonrsharpe said in the comment the issue is the node version. Since rm was added with version 14.14.0 and I am on 14.13.0

like image 79
Ctfrancia Avatar answered Jun 26 '26 22:06

Ctfrancia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!