MaNav MaLhoTra
MaNav MaLhoTra

Reputation: 19

I just installed nodejs in my pc , and did npm -v getting error

    >npm -v
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v17.4.0
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\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 Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)←[39m
←[90m    at node:internal/main/run_main_module:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

Node.js v17.4.0

I installed node on my pc, but it's showing this error, please tell me how to resolve this in windows? I installed node on my pc, but it's showing this error, please tell me how to resolve this in windows? I installed node on my pc, but it's showing this error, please tell me how to resolve this in windows? I installed node on my pc, but it's showing this error, please tell me how to resolve this in windows?

Upvotes: -3

Views: 2184

Answers (3)

venky royal
venky royal

Reputation: 2250

In my case, my partner folder contains the & character in the name that was causing the issue. File hierarchy R&D>remix>blog, changed it to RnD>remix>blog, and it started working fine. For some reason node is unable to find the modules because of those special characters.

Error:

code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: []

Upvotes: 1

Aswin M K
Aswin M K

Reputation: 1

  1. Open "C:\Program Files\nodejs\node_modules\npm\bin"
  2. Right click npm.cmd and click edit
  3. change the following lines

SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js" to SET "NPM_CLI_JS=%~dp0\npm-cli.js"

and

SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js" to SET "NPM_PREFIX_NPM_CLI_JS=%%F\npm-cli.js"

Upvotes: 0

Try uninstall NodeJS and install again

Try to use the stable version: https://nodejs.org/dist/v16.13.2/node-v16.13.2-x64.msi

Upvotes: -2

Related Questions