I actually encountered this recently where it installed a new package via npm but I was using pnpm and when it used npm all sorts of things went haywire. It frustrates me to no end that it doesn't verify my environment every time...
I'm using Claude Code in VS Studio btw.