Bug 1031725 - npm modules installed on a nodejs application are not displayed
npm modules installed on a nodejs application are not displayed
Status: CLOSED CANTFIX
Product: OpenShift Online
Classification: Red Hat
Component: Image (Show other bugs)
2.x
All All
low Severity low
: ---
: ---
Assigned To: Ben Parees
libra bugs
:
: 1031718 (view as bug list)
Depends On: 1031718
Blocks: 1031723
  Show dependency treegraph
 
Reported: 2013-11-18 10:45 EST by Nikhil Mone
Modified: 2015-05-14 20:34 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1031718
Environment:
Last Closed: 2014-01-23 09:48:42 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Nikhil Mone 2013-11-18 10:45:27 EST
+++ This bug was initially created as a clone of Bug #1031718 +++

Description of problem: npm modules installed on a nodejs application are not shown at 'npm ls' or 'npm ls --json'


Version-Release number of selected component (if applicable):


How reproducible:

Everytime

Steps to Reproduce:

1. Create a nodejs application
2. add a dependency/dependencies in "package.json". For eg :

    "dependencies": {
        "yo": "1.x.x",
        "compass": "0.x",
        "bower": "1.x"
    },

3. git add>commit>push, the output shows npm modules are installed.
4. ssh to the application and run 'npm ls --json' or 'npm ls' it does not return the installed npm modules.

Actual results:

ssh to the application and run 'npm ls --json' or 'npm ls' it does not return the installed npm modules.

Expected results:

It should list the installed npm modules

Additional info:
Comment 1 Zhe Wang 2013-11-19 22:20:31 EST
I think the root cause is that node packages are installed under $OPENSHIFT_REPO_DIR/node_modules/ rather than $OPENSHIFT_DEPENDENCIES_DIR/node_modules , but $OPENSHIFT_HOMEDIR/.node_modules (incorrectly?) links to $OPENSHIFT_DEPENDENCIES_DIR/node_modules. Hence, the installed packages will not be displayed when sourcing under $OPENSHIFT_HOMEDIR.

Here is the debugging to support my stand:

1. install the following dependencies:

    "dependencies": {
        "yo": "1.x.x",
        "compass": "0.x",
        "bower": "1.x"
    },

during the installation, we can see from the console that the packages are installed under $OPENSHIFT_REPO_DIR/node_modules/ e.g.,

remote: npm info build /var/lib/openshift/528c1d63ebf58c2441000007/app-root/runtime/repo/node_modules/yo

2. when checking the installed packages under $OPENSHIFT_DEPENDENCIES_DIR/node_modules, we can see that the packages are present under this dir, but $OPENSHIFT_HOMEDIR/.node_modules is linked to it.

lrwxrwxrwx.  1 528c2105ebf58c244100002a 528c2105ebf58c244100002a   78 Nov 19 21:40 .npm -> /var/lib/openshift/528c2105ebf58c244100002a/app-root/runtime/dependencies/.npm

3. sourcing node packages under $OPENSHIFT_HOMEDIR will return an empty list as this bug described.

4. sourcing node packages under $OPENSHIFT_REPO_DIR/ will return the installed packages, for example,

[njs-dev4051tst.dev.rhcloud.com repo]\> npm ls | grep yo
└─┬ yo@1.0.4

I am not sure if the different behaviours between $OPENSHIFT_DEPENDENCIES_DIR/node_modules and $OPENSHIFT_REPO_DIR/node_modules are by design, and I would appreciate a lot if you could help to make it clear.
Comment 2 Zhe Wang 2013-11-19 22:28:39 EST
Sorry, in step 2, it should be "we can see that the packages are NOT present under this dir, but $OPENSHIFT_HOMEDIR/.node_modules is linked to it"
Comment 3 Andy Goldstein 2013-11-21 15:58:40 EST
As best I can tell, this has always been the behavior. I tested on a devenv based on stage_528 (which was before we had $OPENSHIFT_DEPENDENCIES_DIR), and running "npm ls" from the home directory of the gear returns 0 modules, even if you have some installed. If you cd into app-root/runtime/repo and run "npm ls" it will display whatever modules you have installed.

We can create a Trello card if you'd like for trying to install application npm modules into $OPENSHIFT_DEPENDENCIES_DIR/nodejs/node_modules instead of app-root/runtime/repo/node_modules, but I'm not sure of the feasibility and/or implications of doing that.
Comment 4 Ben Parees 2014-01-14 17:35:33 EST
I do not think this is ever going to work as the reporter desires since npm will only report modules installed under the working directory, and rhc ssh will never take you to either the app-root or the dependencies directory, which are the two places the modules can be installed.
Comment 5 Ben Parees 2014-01-16 10:47:03 EST
*** Bug 1031718 has been marked as a duplicate of this bug. ***

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