To resolve this, I upgraded npm from version 9.3.1 to 9.8.1, which works perfectly with Node.js v18.14.0. (My current use case)
You can check your latest compatible version of npm with your nodeJs and update it. There is no need to reinstall the nodeJs.
You can check here: https://nodejs.org/en/about/previous-releases#:~:text=partner%20HeroDevs.-,Looking%20for%20latest%20release%20of%20a%20version%20branch%3F,-Node.js%20Version
npm install -g npm@<YOUR_NPM_VERSION>