I have installed NodeJs today. When I am checking the version of npm in cmd, it has given me some errors. I have tried so many times to solve those problems, but I have failed to solve those problems. Please help me to solve those problems.
The code where I've found error:
npm -v
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module '../lib/utils/unsupported.js'
Require stack:
- C:\Users\IT Master BD\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\IT Master BD\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
←[90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m
←[90m at Module.require (node:internal/modules/cjs/loader:1005:19)←[39m
←[90m at require (node:internal/modules/cjs/helpers:94:18)←[39m
at module.exports (C:\Users\IT Master BD\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:10:7)
at Object.<anonymous> (C:\Users\IT Master BD\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\bin\npm-cli.js:2:25)
←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: [
←[32m'C:\\Users\\IT Master BD\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
←[32m'C:\\Users\\IT Master BD\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
]
}
CodePudding user response:
Generally I would recommend installing NVM package. There are Windows, MacOs and Linux versions of it. Delete the node files you have installed (if on Windows from Start-> Control Panel) and start a clear installation using your terminal and NVM. You should use nvm install node or nvm install version_number, where version_number is the Node version you will need for your project. You can also easily switch Node versions (with which the npm version will also switch) using NVM commands and work on different Node versions in different projects if this is what is needed.
CodePudding user response:
Your npm
install may be corrupt. You can try deleting (or renaming, to be sure) C:\Users\IT Master BD\AppData\Roaming\npm\node_modules\npm
. This way, npm
should fall back to c:\Program Files\nodejs\node_modules\npm
(the version that came packaged with nodejs).
You should then be able to reinstall an updated version of npm with npm i -g npm
.