Bug 1147762 - Cannot Install NPM Packages on Non-Standard OpenShift Cartridges
Summary: Cannot Install NPM Packages on Non-Standard OpenShift Cartridges
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: ---
Assignee: Ben Parees
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-30 03:43 UTC by nmagerko
Modified: 2015-05-15 00:45 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-01 20:57:13 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description nmagerko 2014-09-30 03:43:32 UTC
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.

Comment 1 Ben Parees 2014-09-30 18:26:02 UTC
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

Comment 2 nmagerko 2014-09-30 21:37:22 UTC
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!

Comment 3 Ben Parees 2014-10-01 07:45:50 UTC
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

Comment 4 nmagerko 2014-10-01 20:57:13 UTC
After quite a bit of surgery, it looks like I've got it working. Thanks, Ben.


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