'npm install -g yo generator-code install issue [duplicate]

Ive been in and out of forums and discord servers all week trying to figure this out. so i installed the npm package in the title and got these warnings:

npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

changed 898 packages, and audited 899 packages in 1m

64 packages are looking for funding
  run `npm fund` for details

7 vulnerabilities (5 moderate, 2 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

so i told a few people and they said that it should run fine. so i ran it with yo code and i got a command not found message returned.

someone said to move my PATH. i did that and reinstalled and it didnt work. finally someone said to use npx yo code and it kind of worked. this is what i got

npx yo code
? ==========================================================================
We're constantly looking for ways to make yo better! 
May we anonymously report usage statistics to improve the tool over time? 
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== No
node:internal/readline/emitKeypressEvents:71
            throw err;
            ^

Error: Current environment doesn't provides some necessary feature this generator needs.
    at new Generator (/home/user/vscode-extension/node_modules/yeoman-generator/lib/index.js:259:13)
    at new module.exports (/home/user/vscode-extension/node_modules/generator-code/generators/app/index.js:32:9)
    at Environment.instantiate (/home/user/vscode-extension/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:336:10)
    at Environment.create (/home/user/vscode-extension/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:313:15)
    at Environment.run (/home/user/vscode-extension/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:372:24)
    at /home/user/vscode-extension/node_modules/yo/lib/cli.js:140:11
    at Array.forEach (<anonymous>)
    at /home/user/vscode-extension/node_modules/yo/lib/cli.js:139:9
    at Environment.resolver.lookup (/home/user/vscode-extension/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:50:12)
    at init (/home/user/vscode-extension/node_modules/yo/lib/cli.js:115:7)

now this is too large to put into google so can someone help me fix this.



Solution 1:[1]

it's a very poor error (no information, let alone improper grammar).

in my case, i had a current version of yeoman-generator for my generator project, and a really old version of the global yo cli... So i fixed mine by npm install -g yo

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Merl