npm 错误找不到模块 './config/core.js'

npm error Cannot find module './config/core.js'

我在使用 npm installnpm -v 命令时遇到 npm 问题。

以下是 npm -v 命令在 Windows 命令提示符中 运行 时的错误日志:

C:\Users\Sameer>npm -v internal/modules/cjs/loader.js:905   throw err;
^

Error: Cannot find module './config/core.js' Require stack:
- C:\Program Files\nodejs\node_modules\npm\lib\npm.js
- C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:25:17
    at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:502:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {   code: 'MODULE_NOT_FOUND',   requireStack: [
    'C:\Program Files\nodejs\node_modules\npm\lib\npm.js',
    'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'   ] } internal/modules/cjs/loader.js:905   throw err;   ^

Error: Cannot find module './config/core.js' Require stack:
- C:\Program Files\nodejs\node_modules\npm\lib\npm.js
- C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:25:17
    at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:502:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {   code: 'MODULE_NOT_FOUND',   requireStack: [
    'C:\Program Files\nodejs\node_modules\npm\lib\npm.js',
    'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'   ] }

我尝试卸载 node.js,也尝试直接安装新的 node.js 安装程序。但是,在卸载和安装 node.js 回滚时,windows 系统出现以下错误:

Node.js uninstall/install error in windows system

Node.js

The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2330.

有任何解决 npm 此类问题的解决方法或建议吗? 或者有什么方法可以卸载 node.js 并安装新版本?

卸载NodeJS,然后删除C:\Program Files\nodejs目录,最后重新安装NodeJS。