Bug 1222167

Summary: devel:languages:nodejs: npmrc/globalconfig move to /usr/etc?
Product: [openSUSE] openSUSE.org Reporter: Andrew Daugherity <adaugherity>
Component: 3rd party softwareAssignee: Adam Majer <amajer>
Status: NEW --- QA Contact: E-mail List <screening-team-bugs>
Severity: Normal    
Priority: P5 - None    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Andrew Daugherity 2024-03-29 17:40:25 UTC
I'm not sure if this is a bug or an intentional change (either local or upstream), but since this has happened before (#1144919), I'm seeking clarity.

Basically, as of Node.js 16 the system-wide npmrc file, whose location can be queried with 'npm get globalconfig', has moved from /etc/nodejs/npmrc to /usr/etc/npmrc, and my settings in /etc/nodejs/npmrc are no longer being read.

For all versions of Node <= 14 (except 8, briefly), the path was /etc/nodejs/npmrc, but with >= 16 it's now /usr/etc/npmrc.  I know there's been an effort to put "distribution" settings in /usr/etc and "sysadmin" settings in /etc but AFAIK Node.js has not been patched for this?

Obviously I can move or symlink the file if it's an intended change.  In that old bug you mentioned it depending on prefix (globalconfig = $prefix/etc/npmrc), but that doesn't seem to track 100%.  Here's the output of a simple shell script to query 'npm$ver get globalconfig' and 'npm$ver get prefix':

Version	globalconfig	prefix
10:	/etc/nodejs/npmrc	/usr/local
14:	/etc/nodejs/npmrc	/usr/local
16:	/usr/etc/npmrc	/usr
18:	/usr/etc/npmrc	/usr
20:	/usr/etc/npmrc	/usr
21:	/usr/etc/npmrc	/usr

Despite the /usr prefix, 'npm21 install -g <something>' does still put it under /usr/local/lib/node_modules as intended, keeping /usr/lib64/node_modules for those installed as RPMs.

Thanks for any clarification you can provide (or fixes if needed)!
Comment 1 Andrew Daugherity 2024-03-29 18:01:51 UTC
Well, I see now that npm14 is the "legacy" 6.x; npm16 is 8.x and npm18 and newer is 10.x, and they take different syntaxes (e.g. "production=true" vs. "omit=dev"), so perhaps it's a good thing after all that the "legacy" and "new" npm use different config locations?