-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
Bugthing that needs fixingthing that needs fixingNeeds Triageneeds review for next stepsneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releasework is associated with a specific npm 8 release
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
If a project directory belongs to a linux regular user, all npm scripts in it cannot be run as root.
This problem doesn't exist on npm v6.x
Expected Behavior
When logged in as root, or running npm script with sudo, the scripts should be run as root.
Steps To Reproduce
zim@desktop:~$ mkdir ./haha
zim@desktop:~$ cd ./haha
zim@desktop:~/haha$ emacs ./package.json~/haha/package.json:
{
"name": "haha",
"scripts": {
"test": "whoami"
}
}
zim@desktop:~/haha$ sudo npm run test
[sudo] password for zim:
> test
> whoami
zimzim is a regular user.
Environment
- npm: 8.1.3
- Node: 16.13.0
- OS: Ubuntu 20.04
- platform: amd64
- npm config:
; "user" config from /home/zim/.npmrc
registry = "https://repo.huaweicloud.com/repository/npm/"
; node bin location = /usr/local/bin/node
; cwd = /home/zim/haha
; HOME = /home/zim
; Run `npm config ls -l` to show all defaults.My npm and node are installed from n
jonathanhefnerpapbArturDorochowicz
Metadata
Metadata
Assignees
Labels
Bugthing that needs fixingthing that needs fixingNeeds Triageneeds review for next stepsneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releasework is associated with a specific npm 8 release