Проблема:
Когда вы пытаетесь запустить любую команду npm, такую как npm start, вы видите сообщение об ошибке, например
error.txt
/usr/lib/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> (/usr/lib/node_modules/npm/node_modules/fs-minipass/lib/index.js:136:4)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:119:18)
at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/cacache/lib/content/read.js:4:13)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)Решение
Это внутренняя ошибка в npm или пакетах, требуемых npm. Обычно она вызвана неполным обновлением NodeJS и npm, которое оставляет npm или его зависимости в сломанном состоянии.
Решение — переустановить NodeJS:
- Удалите NodeJS с помощью команды, такой как
uninstall_node.sh
sudo apt remove nodejs- Полностью удалите папку пакетов NodeJS, на Linux её можно переместить в резервное расположение, например, с помощью
backup_node_modules.sh
sudo mv /usr/lib/node_modules ~/node_modules_backup- Переустановите NodeJS с помощью команды, такой как
install_node.sh
sudo apt -y install nodejs- Переустановите любые глобально установленные пакеты, которые вам нужны, например,
npm i -g @angular/cli
Check out similar posts by category:
NodeJS
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow