Skip to content

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

Closed

Description

@yltx

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.

Activity

  1. added
    Bugthing that needs fixing
    Needs Triageneeds review for next steps
    Release 8.xwork is associated with a specific npm 8 release
    on May 10, 2022
  2. yltx commented on May 10, 2022

    @yltx
    Author

    OK it has been fixed.

  3. weironz commented on Jul 5, 2022

    @weironz

    run follow for china

    npm cache clear --force
    npm config set registry https://registry.npmmirror.com
    
  4. Xiamu-ssr commented on Dec 17, 2022

    @Xiamu-ssr

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

  5. itchenfei commented on May 7, 2023

    @itchenfei

    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

  6. dhruvdey0907 commented on May 25, 2023

    @dhruvdey0907

    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

  7. siblount commented on Feb 15, 2024

    @siblount

    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.

  8. Hassanzamir47 commented on Dec 20, 2024

    @Hassanzamir47

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions