在设备上重新安装 Windows 后出现此错误:TypeError:类扩展值未定义不是构造函数或 null

问题描述 投票:0回答:1

我刚刚修复了设备并重新安装了 Windows。在此过程中,大量应用程序和程序从我的设备中删除,包括 VSCode 和 Node.js。我曾经有node-v19.4.0-x64,但我刚刚下载了node-v21.6.2-x64,最新版本。从那时起我就无法在 VSCode 中使用 npm 命令了。无论我在哪个项目或使用哪个命令,都会出现此错误:

C:\Program Files\nodejs\node_modules\npm\lib\es6\validate-engines.js:31
    throw err
    ^

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\fs-minipass\lib\index.js:136:4)
    at Module._compile (node:internal/modules/cjs/loader:1378:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)      
    at Module.load (node:internal/modules/cjs/loader:1212:32)
    at Module._load (node:internal/modules/cjs/loader:1028:12)
    at Module.require (node:internal/modules/cjs/loader:1237:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\cacache\lib\content\read.js:4:13)
    at Module._compile (node:internal/modules/cjs/loader:1378:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)

我已经多次尝试卸载并重新安装节点。我还尝试安装 Node 的 LTS 版本。

node.js visual-studio-code
1个回答
0
投票

我在同样的情况下遇到了同样的错误。从我的项目中删除旧的

node
node_modules
目录解决了这个问题。

有趣的是,

minipass
也是触发错误的文件。

这些是我采取的步骤:

  1. 升级了我的 NPM
    npm update -g npm
  2. 删除了项目的本地
    node
    目录(从mvn build创建)
  3. 删除了项目本地的
    node_modules
    目录
© www.soinside.com 2019 - 2024. All rights reserved.