Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm config edit user or group - not working #3441

Open
1 task done
shaybc opened this issue Jun 19, 2021 · 2 comments
Open
1 task done

npm config edit user or group - not working #3441

shaybc opened this issue Jun 19, 2021 · 2 comments
Labels
platform:windows is Windows-specific Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@shaybc
Copy link

shaybc commented Jun 19, 2021

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
@shaybc shaybc added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Jun 19, 2021
@wraithgar
Copy link
Member

Those are the v6 docs you linked. The user config option is not present in npm v7. In order to run as a different user, npm must be ran as root and then scripts will be run with the effective uid and gid of the current working directory owner: https://docs.npmjs.com/cli/v7/using-npm/scripts#user

@wraithgar wraithgar added Needs Discussion is pending a discussion and removed Bug thing that needs fixing Needs Triage needs review for next steps labels Jun 21, 2021
@shaybc
Copy link
Author

shaybc commented Jun 21, 2021

Those are the v6 docs you linked. The user config option is not present in npm v7. In order to run as a different user, npm must be ran as root and then scripts will be run with the effective uid and gid of the current working directory owner: https://docs.npmjs.com/cli/v7/using-npm/scripts#user

wraithgar thanks for the correction and asnwer,
i am running on a windows system (so there instead of root i use Administrator), i have ran the cmd as Administrator, the folder i am using is owned by MyUser, and the package is installed to global (-g) and still when run it is not executed using MyUser

@wraithgar wraithgar added Priority 2 secondary priority issue platform:windows is Windows-specific and removed Needs Discussion is pending a discussion labels Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows is Windows-specific Priority 2 secondary priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

2 participants