npm / npm/cli

npm config edit user or group - not working

Open
#3,441 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

platform:windows Priority 2 Release 7.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
Current Behavior

when executing npm package executable on a policy restricted PC the user/group config does not take into effect,

i am on an enterprise windows PC, after installing npm-gui (also happens on nx.dev StoryBoard),
when i run a command that tries to launch a server (listen to a port), it execute it with the DefaultAccount, the output say: [as default]

the PC has a policy that one user cannot execute applications as another user,

so i tried setting the user (UID) or group (GID) so npm will use that user to execute the commands, but it does not effect the process

actual received output:

C:\Test>npm-gui
listening on:  localhost 13377
node:internal/errors:456
    ErrorCaptureStackTrace(err);
    ^

Error: spawn EPERM
    at ChildProcess.spawn (node:internal/child_process:415:11)
    at Object.spawn (node:child_process:609:9)
    at Object.open [as default] (C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm-gui\node_modules\open\index.js:204:34) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'spawn'
}

Expected Behavior

setup UID to use when executing npm package executables
as stated at: https://docs.npmjs.com/cli/v6/using-npm/config#user

set:
npm config set user MYUsername

call:
npm-gui

expect server to launch properly and to see npm-gui UI
as shown here: https://www.npmjs.com/package/npm-gui

Steps To Reproduce
  1. on a PC with policy that disallow running as another user (or where DefaultAccount is disabled)
  2. install node 16.3.0
  3. run: npm i -g npm-gui
  4. run: npm config set user=MyUsername
  5. run: npm-gui

in step 3 i also tried: npm config set group=MY_GID as stated here: https://docs.npmjs.com/cli/v6/using-npm/config#group

Environment
  • OS: Windows 10
  • Node: 16.3.0
  • npm: 7.18.1

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 the Windows 10 behavior with Node 16.3.0, npm 7.18.1, npm-gui, and the documented user and group configuration commands. Read the npm config documentation for user and group, then trace how those settings affect package executable launches; done means the configured identity is honored and npm-gui starts without the spawn EPERM error.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.