npm / npm/cli

`npm config` fails in workspaces

Open
#6,099 13 comments 26 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 10.x 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

Since npm@9.3.0 calling
npm config list or
npm config get registry
inside a workspace of a worktree results in an error:

❯ npm config list
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

Here's part of the log:

28 timing npm:load:logFile Completed in 12ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 0ms
31 timing npm:load Completed in 46ms
32 timing command:config Completed in 1ms
33 verbose stack Error: This command does not support workspaces.
33 verbose stack     at Config.cmdExec (...\node_modules\npm\lib\base-command.js:123:29)
33 verbose stack     at Npm.exec (...\node_modules\npm\lib\npm.js:154:20)
33 verbose stack     at async module.exports (...\node_modules\npm\lib\cli.js:134:5)

It used to work in 9.2.0.

Expected Behavior

Well, show (and use!) all configs.

Steps To Reproduce

Build a worktree with packages. .npmrc in root. In a package call npm config list.

Environment
  • npm: 9.4.0
  • Node.js: 18.13.0
  • OS Name: Windows 10
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here

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 npm config list and npm config get registry from a workspace package, then inspect the command flow at lib/base-command.js, lib/npm.js, and lib/cli.js mentioned in the stack. Done means these commands work from a workspace or worktree package and show and use the applicable configuration without ENOWORKSPACES.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.