任何 npm 命令都会返回错误“找不到模块 yallist”,甚至 npm -v

Jos*_*tor 5 npm

(node:2564) UnhandledPromiseRejectionWarning: Error: Cannot find module 'yallist'
Require stack:
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\lru-cache\index.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\range.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\comparator.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js
        - C:\Users\23354\AppData\Roaming\npm\node_modules\npm\lib\cli.js
        - C:\Users\23354\AppData\Roaming\npm\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:93:18)
        at Object.<anonymous> (C:\Users\23354\AppData\Roaming\npm\node_modules\npm\node_modules\lru-cache\index.js:4:17)
        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:12)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        (Use `node --trace-warnings ...` to show where the warning was created)
        (node:2564) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error 
        originated either by throwing inside of an async function without a catch block, or by 
        rejecting a promise which was not handled with .catch(). To terminate the node process 
        on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see 
        https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
        (node:2564) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. 
        In the future, promise rejections that are not handled will terminate the Node.js 
        process with a non-zero exit code.
Run Code Online (Sandbox Code Playgroud)

Jos*_*tor 3

我通过卸载节点并删除 Roaming 文件夹中的 npm 文件夹,然后重新启动计算机来解决此问题。

之后我再次安装了节点。现在一切正常。