Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'agentkeepalive' when updating NPM to 7.20.3

Tags:

node.js

npm

nvm

When I'm trying to update npm to 7.20.3 (npm install -g [email protected]), npm throws :

npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module 'agentkeepalive' npm ERR! Require stack: npm ERR! - /Users/ShaggyRogers/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/make-fetch-happen/agent.js ... 
like image 237
Thibault Walterspieler Avatar asked Aug 02 '21 08:08

Thibault Walterspieler


2 Answers

In order to quickly fix this error just install or re-install globally agentkeepalive :

npm install -g agentkeepalive --save 

Then update npm :

npm install -g [email protected] 

UPDATE :

Since June 23 2021, the bug seems to be fixed in v7.17.0 (GitHub issue)

You can first upgrade to v7.17.0:

npm install -g [email protected] 

Then upgrade to the last version of npm :

npm install -g [email protected] 

or

npm install -g npm@latest 
like image 86
Thibault Walterspieler Avatar answered Sep 18 '22 12:09

Thibault Walterspieler


This has been discussed on github

TL;DR;

It has been fixed in npm v7.17.0 and newer. I managed to upgrade from 7.10.0 to 7.21.0 and avoid this error entirely (and not dealing with agentkeepalive) by upgrading first to 7.17.0 and then to 7.21.0.

like image 34
tromgy Avatar answered Sep 20 '22 12:09

tromgy