npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

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

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:


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.