Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Failed to install any package with ERROR Code"npm ERR! Cannot read property 'insert' of undefined" #4876

Closed
2 tasks done
yltx opened this issue May 10, 2022 · 7 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@yltx
Copy link

yltx commented May 10, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Why I don't use the latest version of npm:I even can't update npm by using "sudo npm i -g npm".

The environment information:

node version: v12.22.9

npm version: v8.5.1

WSL version:

Build: 22598

Release: Ubuntu 22.04 LTS

Kernel: Linux 5.10.102.1-microsoft-standard-WSL2

This problem also exists in these websites:

https://serveanswer.com/questions/npm-install-error-npm-err-cannot-read-property-insert-of-undefined

https://stackoverflow.com/questions/72004247/npm-install-error-npm-err-cannot-read-property-insert-of-undefined/72183748#72183748

They use the same version of node and npm as I , but I can't know if they are also using WSL too.

Expected Behavior

Install normally.

Steps To Reproduce

sudo npm i -g npm

Actually , whatever package I install , it fails with the same ERROR Code.

Environment

  • npm:8.5.1
  • Node.js:12.22.9
  • OS Name:WSL2
  • System Model Name:Windows Subsystem for Linux
  • npm config:
; "builtin" config from /usr/share/nodejs/npm/npmrc

globalignorefile = "/etc/npmignore"
; prefix = "/usr/local" ; overridden by project

; "user" config from /home/yltx/.npmrc

https-proxy = "http://172.31.160.1:10087/"
proxy = "http://172.31.160.1:10087/"
; registry = "https://registry.npmmirror.com/" ; overridden by project

; "project" config from /mnt/c/Users/yltx/.npmrc

prefix = "/mnt/c/Users/yltx/C:\\Windows\\System32"
registry = "https://registry.npmmirror.com/"

; node bin location = /usr/bin/node
; cwd = /mnt/c/Users/yltx
; HOME = /home/yltx
; Run `npm config ls -l` to show all defaults.
@yltx yltx added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels May 10, 2022
@yltx
Copy link
Author

yltx commented May 10, 2022

OK it has been fixed.

@yltx yltx closed this as completed May 10, 2022
@willzhang
Copy link

willzhang commented Jul 5, 2022

run follow for china

npm cache clear --force
npm config set registry https://registry.npmmirror.com

@Xiamu-ssr
Copy link

when i update node version to v18.12.1 and npm still is v8.5.1, problem solved

@itchenfei
Copy link

i got this error when set registry to http://registry.npmmirror.com
but actually registry is https://registry.npmmirror.com

so:

npm cache clear --force
npm config set registry https://registry.npmmirror.com

is the best answer

@dhruvdey0907
Copy link

npm ERR! Cannot read property 'insert' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-05-25T07_14_35_384Z-debug-0.log

why am i getting this

@siblount
Copy link

I got this error after clearing cache trying to fix the stuck sill idealTree buildDeps issue. I ended up doing npm cache clear --force then setting npm config set registry http://registry.npmjs.org giving me this error.

@itchenfei's response helped. Changing the URL scheme from http to https did the trick.

@Hassanzamir47
Copy link

Hassanzamir47 commented Dec 20, 2024

when i update node version to v18.12.1 and npm still is v8.5.1, problem solved

I am using Ubuntu 22, I have used these versions using these commands so it worked for me:
sudo apt remove -y nodejs npm
sudo apt autoremove -y
sudo apt update

sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

node -v

Should output: v18.12.1

sudo npm install -g npm@8.5.1

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

7 participants