npm / npm/cli

[BUG] Cannot read property 'pickAlgorithm' of null

Open
#5,496 13 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 1
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

re-raising #3374 as it was closed without a proper solution.

for many users this occurs on every npm install, meaning we have to run npm cache clean --force every time.

Is there an existing issue for this?
* [x]  I have searched the existing issues
Current Behavior

Whenever typing an npx function, I receive an error. It seems that NPM, itself, is broken on my device.

When typing npx create-react-app testing in my terminal, I receive the following error: Invalid response body while trying to fetch https://registry.npmjs.org/create-react-app: Cannot read property 'pickAlgorithm' of null

Which produces the below error log: 2021-06-06T03_09_42_989Z-debug.log

Expected Behavior

I was not expecting an error to occur. I was expecting an application to be created.

Steps To Reproduce
1. In this environment...
   I am on Ubuntu and typing into my terminal. I was attempting to install jest for testing in a react project, and I accidentally typed "npm install --save-dev jes" instead (notice the missing t). I aborted that command a few seconds after my terminal started logging changes, and my npm has been broken since.

2. With this config...
   This problem isn't specific to any project - it is an issue across my entire directory.

3. Run '...'
   As stated, I originally ran  "npm install --save-dev jes".

Afterwards, when I tried creating the testing application, which resulted in my terminal spewing countless lines of errors before telling me that I should log this issue.

I then tried to create my testing application again, but this time I received an error stating I don't have enough space on my device, which made me think that the prior error consumed space on my device. I checked my storage with df -h, and I saw that my /dev/sdal, /dev/loop0, and /dev/loop1 folders were all full. I cleared my trash folder, and then I ran npm cache clean --force to try and lower the storage, but only /dev/sdal went down (and only to 90%).

4. See error...
   Now when I try to create my testing application, the error I see is as the one in my Current Behavior description.
   Invalid response body while trying to fetch https://registry.npmjs.org/create-react-app: Cannot read property 'pickAlgorithm' of null
Environment
* OS: Ubuntu 20.04

* Node: v14.1.0

* npm: 7.16.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with npm install --save-dev jes followed by the reported npx create-react-app testing command on Ubuntu with Node v14.1.0 and npm 7.16.0, then inspect the linked debug log. Done means interrupted or malformed installs no longer leave npm unable to fetch packages or report the pickAlgorithm error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.