Skip to content

[Feature] Add support ignoring parent node_modules for monorepos? #73

Open

Description

@MaxmaxmaximusGitHub

Add support ignoring parent node_modules for monorepos?

Activity

  1. MaxmaxmaximusGitHub commented on May 26, 2020

    @MaxmaxmaximusGitHub
    Author

    like this

    utils.js:

    exports.getModulesNamesFromDirLocal = function getModulesNamesFromDirLocal(dir) {
      return exports.readDir(path.resolve(dir, './node_modules')).filter(x => {
        return !exports.contains(['.bin'], x)
      })
    }
    
    
    exports.getModulesNamesFromDir = function getModulesNamesFromDir(dir) {
      const allFoundModules = []
      const pathParts = dir.split(path.sep)
    
      for (let i = pathParts.length - 1; i >= 0; i--) {
        const parentDirs = pathParts.slice(0, i)
        const parentPath = parentDirs.join(path.sep)
        const foundModules = exports.getModulesNamesFromDirLocal(parentPath)
        allFoundModules.push(...foundModules)
      }
    
      return allFoundModules
    }
  2. liady commented on Jul 8, 2020

    @liady
    Owner

    In version 2 you can pass additionalModuleDirs to options. Do you think this functionality (looking up the tree) is still needed?

  3. MaxmaxmaximusGitHub commented on Aug 3, 2020

    @MaxmaxmaximusGitHub
    Author

    @liady this functionality should work by default since node_modules has tree-floating semantics.

  4. aprilandjan commented on Aug 9, 2020

    @aprilandjan

    @liady Yeah this is definitely needed when using yarn workspace or lerna, it will be good if it matches with current module resolving strategies.

  5. akomm commented on May 10, 2021

    @akomm

    In version 2 you can pass additionalModuleDirs to options. Do you think this functionality (looking up the tree) is still needed?

    Yes its needed. Why should a package explicitly point to a directory, which is out of responsibility of this package? (node_modules in monorepo root for example).

  6. Kadeluxe commented on May 25, 2021

    @Kadeluxe

    Maybe it could be an option such as scanParents or something like this. Although personally I'm OK with additionalModuleDirs because in my monorepo projects I have project-specific build setups anyway.

  7. added a commit that references this issue on Mar 3, 2026
    8f6650a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions