Description of problem: While using a non-standard cartridge for nginx (https://github.com/gsterjov/openshift-nginx-cartridge) on OpenShift, I found that it is not possible for the common user to "npm install" any packages, due to a lack of permissions. Indeed, npm complains of an EACCESS at ~/.npm, and requests that I elevate my privileges. Version-Release number of selected component (if applicable): How reproducible: Only tested this on a single cartridge not maintained by OpenShift, so there may just be some developer misconceptions here. Steps to Reproduce: 1. Install non-openshift-maintained cartridge 2. Deploy 3. Either in build hook or control script, attempt to install npm packages in a subfolder Actual results: NPM reports an EACCESS at ~/.npm Expected results: Considering that OpenShift has npm already available to its users regardless of what cartridge they are running, it seems to me as though I should be able to npm-install no matter what cartridge I start out with.
The nodejs cartridge creates this directory such that it's user writeable. It doesn't really make sense to force all existing cartridges to do the same, or to arbitrarily make that directory in all gears. However you can select a different directory for npm to install to, is that not sufficient for your requirements? https://stackoverflow.com/questions/14469515/how-to-npm-install-to-a-specified-directory
Well, this does not appear to change the location of .npm; it only changes where packages would get installed to (if I could install them, that is). The problem lies in the fact that npm needs access to ~/.npm, but in order to change the location of .npm, I believe that I also need to access .npmrc, which I am not permitted to create/modify. Thus, since I cannot create/access .npm or .npmrc, I am stuck!
you can set the userconfig parameter to control the location of npmrc https://www.npmjs.org/doc/misc/npm-config.html looks like you set it via an env variable: npm_config_userconfig=/path
After quite a bit of surgery, it looks like I've got it working. Thanks, Ben.