Setting npm config key as root appears to nullify all default keys


(Ralph Drake) #1

I found this issue when attempting to hunt down another issue. As my standard user account, I don’t need any intervention when installing NPM packages with custom scripts (in this case benchpressjs. However, with sudo or as root, such install scripts fail whenever a directory change is required (see this issue on GitHub).

In an attempt to fix this, I changed to root and ran the command npm config set script-shell /bin/bash. After running this command, attempting to install the package produced the following error:

/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined

(Here is the full debug log)

Is there a reason the root user would be having these issues while my standard user account doesn’t? The identical commands work perfectly when run as my default user.


System info:

  • Ubuntu Server 18.04 4.15.0-39-generic
  • Node v10.13.0
  • NPM 6.4.1

(Lars Willighagen) #2

Possibly related:

Note: You attached the wrong debug log, I think.

Can’t reproduce this myself, which is a shame because this looks fun to debug. Here’s probably the starting point, for anyone interested.


(system) #3

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.