How to fix "fs.rmSync is not a function" error

Endrit Qerreti

Endrit Qerreti

In this tutorial you will learn how to fix the error fs.rmSync is not a function. This error happens when node version it's too old and it doesn't support the fs.rmsyc function, to fix this issue simply follow the steps in this tutorial.

Step 1 - Check node version

To check node version that you have installed on your computer run

node --version


owlhowto@owlhowto:~$ node --version

We are using node v12.22.9 to reproduce this error since this function it's not supported by this version of node.

Step 2 - Install n package

n is the name of the package that can manage node versions, to be able to install or update node by using this package we need to install it first

sudo npm install -g n

If you don't have npm package installed on your computer install it via this command

sudo apt install npm

Once n and npm are installed on your system, move to the next step and update your nodejs version.

Step 3 - Update node to LTS/Stable

The difference between LTS and stable is that, LTS will be more stable in terms of updates and stability and it is recommended to use it in production, stable in other hand will also be stable. However, it is not recommended for production because of frequent updates which means more bugs too and untested features.  This is up to you with which version you go with, go with the one you think your app/project will run better.

To update nodejs package run the following command

sudo n lts

The above command will update node to the Long Term Support version, if you want to install the stable version instead use the stable command

n stable

Step 4  - Check if the error is gone

Once you install the latest or stable version of node, check if the error is gone. The support for this function was added on node version 14.14, for example we installed the LTS version which is Node.js v18.15.0 and the issue was fixed.


In this tutorial you learned how to fix the error "fs.rmSync is not a function". This issue happened because we were using an old version of node which did not support this function.

You should be able to use this function now after fixing this issue by following the steps in our tutorial.