Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving local/nested node_modules folder #161

Open
walisc opened this issue Jun 30, 2023 · 0 comments · May be fixed by #162
Open

Resolving local/nested node_modules folder #161

walisc opened this issue Jun 30, 2023 · 0 comments · May be fixed by #162

Comments

@walisc
Copy link

walisc commented Jun 30, 2023

There are cases that arise when a node module specifies it's own node_modules folder (for instance when wanting to tie itself to a particular version of a package). Example below:

./
├── app.js
└── node_modules
    └── packageA
        ├── index.js
        └── node_modules
            └── child_packageA
                └── index.js

In the case above, requiring

 dependencyTree({
        "app.js",
        "./",
        isListForm: true
      });

should return the dependencies

[
 "./node_modules/packageA/index.js",
 "./node_modules/packageA/node_modules/child_packageA/index.js"
]

which is does not.


Another issue is that if the base node_modules has a version of child_packageA, it will refer to that as a dependency, which is wrong (and can have adverse effects if it is a different version of the package). For instance

./
├── app.js
└── node_modules
    ├── child_packageA
    │   └── index.js
    └── packageA
        ├── index.js
        └── node_modules
            └── child_packageA
                └── index.js

Returns

[
 "./node_modules/packageA/index.js",
 "./node_modules/child_packageA/index.js"
]

The main issue is related to the directory used when passing a file to precient to get the dependencies. When the file is part of node module/package, the directory should be the root of that package (as all files are contained in there)

Pull request #162 is a potential fix for this.

@walisc walisc linked a pull request Jun 30, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant