npm / npm/cli

[BUG] EINVALIDPACKAGENAME on npm update -g - PART II

Open
#6,425 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 9.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

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

Running

npm update -g

without specifying any package - i.e. update all global packages, throws this error:

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name ".npm-qUIFSsiV" of package ".npm-qUIFSsiV@*": name cannot start with a period.

Specifying package(s) will update these packages with no problems.

Note that I can not update to latest npm version due to the following error:

$ npm i -g npm@9
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/npm
npm ERR! dest /usr/lib/node_modules/.npm-qUIFSsiV
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'

Solution was to delete directory /usr/lib/node_modules/.npm-qUIFSsiV and both upgrading npm and npm update -g worked again.

Related: #2835

Expected Behavior

npm updates all global packages normally.

Steps To Reproduce

Run npm update -g in a terminal.

Environment
  • npm: 9.6.6
  • Node.js: v18.16.0
  • OS Name: Ubuntu 22.04.2 LTS
  • System Model Name: VirtualBox
  • npm config:
; node bin location = /usr/bin/node
; node version = v18.16.0
; npm local prefix = /home/services
; npm version = 9.6.6
; cwd = /home/services
; HOME = /home/services
; Run `npm config ls -l` to show all defaults.

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

No file or test is named. Start by reproducing npm update -g with npm 9.6.6 on the stated environment, then trace the global-update path and its handling of the temporary .npm-* directory. Done means global packages update without EINVALIDPACKAGENAME or requiring manual directory deletion.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.