Skip to content

[BUG] npm completion does not support workspaces #5895

@remcohaszing

Description

@remcohaszing

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

When running npm completion from an npm workspace, it shows the following error:

$ npm completion   
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/remco/.cache/npm/_logs/2022-11-25T10_09_50_122Z-debug-0.log
logs
0 verbose cli /usr/bin/node /home/remco/.local/bin/npm
1 info using npm@9.1.2
2 info using node@v18.12.1
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/home/remco/.local/lib/node_modules/npm/npmrc Completed in 2ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 info found workspace root at /home/remco/Projects/vscode-mdx
10 timing config:load:file:/home/remco/Projects/vscode-mdx/.npmrc Completed in 0ms
11 timing config:load:project Completed in 9ms
12 timing config:load:file:/home/remco/.npmrc Completed in 1ms
13 timing config:load:user Completed in 1ms
14 timing config:load:file:/home/remco/.local/etc/npmrc Completed in 0ms
15 timing config:load:global Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 16ms
18 timing npm:load:configload Completed in 16ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm completion
22 verbose argv "completion"
23 timing npm:load:setTitle Completed in 1ms
24 timing config:load:flatten Completed in 1ms
25 timing npm:load:display Completed in 2ms
26 verbose logfile logs-max:10 dir:/home/remco/.cache/npm/_logs/2022-11-25T10_09_50_122Z-
27 verbose logfile /home/remco/.cache/npm/_logs/2022-11-25T10_09_50_122Z-debug-0.log
28 timing npm:load:logFile Completed in 1ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 0ms
31 timing npm:load Completed in 21ms
32 silly logfile start cleaning logs, removing 2 files
33 timing config:load:flatten Completed in 0ms
34 timing command:completion Completed in 0ms
35 verbose stack Error: This command does not support workspaces.
35 verbose stack     at Completion.execWorkspaces (/home/remco/.local/lib/node_modules/npm/lib/base-command.js:102:25)
35 verbose stack     at Npm.exec (/home/remco/.local/lib/node_modules/npm/lib/npm.js:184:31)
35 verbose stack     at async module.exports (/home/remco/.local/lib/node_modules/npm/lib/cli.js:133:5)
36 verbose cwd /home/remco/Projects/vscode-mdx/packages/language-server
37 verbose Linux 6.0.6-76060006-generic
38 verbose node v18.12.1
39 verbose npm  v9.1.2
40 error code ENOWORKSPACES
41 error This command does not support workspaces.
42 verbose exit 1
43 timing npm Completed in 30ms
44 verbose code 1
45 error A complete log of this run can be found in:
45 error     /home/remco/.cache/npm/_logs/2022-11-25T10_09_50_122Z-debug-0.log

Expected Behavior

npm completion just works as usual when inide a workspace.

Steps To Reproduce

  1. Navigate to a workspace inside an npm mono repo.
    git clone git@github.com:npm/cli.git
    cd cli/workspaces/arborist
  2. Run npm completion
  3. See error

Environment

  • npm: 9.1.2 (also happened in npm 8)
  • Node.js: v18.12.1
  • OS Name: Pop!_OS
  • System Model Name:
  • npm config:
; "user" config from /home/remco/.npmrc

cache = "/home/remco/.cache/npm" 
init-author-email = "remcohaszing@gmail.com" 
init-author-name = "Remco Haszing" 
init-license = "MIT" 
prefix = "/home/remco/.local" 

; node bin location = /usr/bin/node
; node version = v18.12.1
; npm local prefix = /home/remco
; npm version = 9.1.2
; cwd = /home/remco
; HOME = /home/remco
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 9.xwork is associated with a specific npm 9 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions