In the head of your file, just add
const path = require('path');
did you require path module
const path = require('path')