After seeing this post and other resources, I wanted to try using NPM programmatically so simply I tried:
const npm = require('npm');
but I run into an error of Error: Cannot find module 'npm'
.
I did some research and all I saw was to try running npm install npm@latest -g
which just updates NPM if I'm not mistaken but I ran it anyways and no change. NPM is already installed globally and I did try installing it locally which got rid of the error but broke the rest of my project so I assume there's a reason that wasn't recommended.
All of the posts I've seen have been older so is this not supported anymore? All the documentation I can find is about the cli and not using it as a module.