Bug 31468 - Missing write access for /usr/lib/node_modules/ when running npm install --global yarn to install yarn
Summary: Missing write access for /usr/lib/node_modules/ when running npm install --gl...
Status: RESOLVED WORKSFORME
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 8
Hardware: x86_64 Linux
Priority: Normal major
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-28 15:15 CET by Kristoffer Grundström
Modified: 2023-05-30 20:51 CEST (History)
2 users (show)

See Also:
Source RPM: npm
CVE:
Status comment:


Attachments
Complete log file (2.33 KB, text/plain)
2023-01-28 15:17 CET, Kristoffer Grundström
Details

Description Kristoffer Grundström 2023-01-28 15:15:38 CET
Description of problem: I believe that there is a permission issue with the execution of the npm command to install yarn.

Running ls /usr/lib/node_modules/ shows that root owns both directories even though I haven't runned the install command as sudo or as root:

[kristoffer@Desktop ~]$ ls -ls /usr/lib/node_modules/
totalt 8
4 drwxr-xr-x 4 root root 4096 jan 28 15:05 corepack/
4 drwxr-xr-x 8 root root 4096 jan 28 15:05 npm/


I know that it's not recommended to run anything as root unless one knows what they're doing so I don't know what needs to be solved with the npm package for future releases.

Version-Release number of selected component (if applicable): 6.14.17

How reproducible: All the time.

Steps to Reproduce:
1. Install npm.
2. Run npm install --global yarn.
3. npm fails with a errno -13 message that states Error: EACCES: permission denied, access '/usr/lib/node_modules'
Comment 1 Kristoffer Grundström 2023-01-28 15:17:44 CET
Created attachment 13661 [details]
Complete log file

CC: (none) => lovaren

Comment 2 Kristoffer Grundström 2023-01-28 15:18:18 CET
It mentioned in this issue on the yarn GitHub repo:

https://github.com/yarnpkg/yarn/issues/1806
Comment 3 Kristoffer Grundström 2023-01-28 15:59:09 CET
Searching the issues tab using "access denied" shows that more than me experience this as well.
Comment 4 sturmvogel 2023-01-28 16:12:02 CET
You need to run "sudo npm install --global yarn" or "su -c 'npm install --global yarn'" ....

That's it...
Comment 5 sturmvogel 2023-01-28 16:13:42 CET
Btw why do you expect to have write permission as normal user for /usr/lib/? You need root or sudo rights for it...
Comment 6 Kristoffer Grundström 2023-01-28 20:20:00 CET
(In reply to sturmvogel from comment #4)
> You need to run "sudo npm install --global yarn" or "su -c 'npm install
> --global yarn'" ....
> 
> That's it...

Of course, but if you look at this section for instance, you see that it doesn't mention the need for using sudo or su -c which is odd if you really must use it:

https://github.com/signalapp/Signal-Desktop/blob/main/CONTRIBUTING.md#all-platforms
Comment 7 Lewis Smith 2023-05-30 20:51:23 CEST
Comment 2 leads to the solutions.
1. As already mentioned in comment 4:
 sudo npm i yarn --global
or
 sudo npm install --global yarn
or
 su -c 'npm install --global yarn'

2. remove the node_modules & yarn.lock and run 'yarn'
pr
 deleted node_modules and yarn.lock and run yarn add [libToInstall]

Closing as it is not a Mageia problem, but generic application.

Status: NEW => RESOLVED
CC: (none) => lewyssmith
Resolution: (none) => WORKSFORME


Note You need to log in before you can comment on or make changes to this bug.