I'm trying to use mainModule like this:
const { mainModule } = require('process');
module.exports = path.dirname(mainModule.filename);
But I'm receiving the following messages:
const mainModule: NodeJS.Module 'mainModule' is deprecatedts(6385)
Auto import from 'process' (property) NodeJS.Process.mainModule?: NodeJS.Module
@deprecated — since v14.0.0 - use require.main instead.
How can I Solve this?
I found here that you just need to change this:
const { mainModule } = require('process');
module.exports = path.dirname(mainModule);
To this:
module.exports = path.dirname(require.main.filename);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With