Bug 1031725 - npm modules installed on a nodejs application are not displayed
Summary: npm modules installed on a nodejs application are not displayed
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: All
OS: All
low
low
Target Milestone: ---
: ---
Assignee: Ben Parees
QA Contact: libra bugs
URL:
Whiteboard:
: 1031718 (view as bug list)
Depends On: 1031718
Blocks: 1031723
TreeView+ depends on / blocked
 
Reported: 2013-11-18 15:45 UTC by Nikhil Mone
Modified: 2015-05-15 00:34 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1031718
Environment:
Last Closed: 2014-01-23 14:48:42 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nikhil Mone 2013-11-18 15:45:27 UTC
+++ 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-20 03:20:31 UTC
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.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-20 03:28:39 UTC
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 20:58:40 UTC
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 22:35:33 UTC
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 15:47:03 UTC
*** 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.