code: def install_node_modules(path=None, build_dir=None, source_dir=None, build_cmd='build', force=False):
      
  
      class Yarn(BaseCommand):
          description = 'install package.json dependencies using yarn'
  
          def run(self):
              if skip_yarn:
                  log.info('Skipping yarn-installation')
                  return
              node_package = path or here
              node_modules = os.path.join(node_package, 'node_modules')
  
              if not which("yarn"):
                  log.error("`yarn` unavailable.  If you're running this command "
                            "using sudo, make sure `yarn` is availble to sudo")
                  return
              if force or is_stale(node_modules, os.path.join(node_package, 'package.json')):
                  log.info('Installing build dependencies with yarn.  This may '
                           'take a while...')
                  run(['yarn', 'install'], cwd=node_package)
              if build_dir and source_dir and not force:
                  should_build = is_stale(build_dir, source_dir)
              else:
                  should_build = True
              if should_build:
                  run(['yarn', 'run', build_cmd], cwd=node_package)
  
      return Yarn
docs: Return a Command for managing an node_modules installation.
      Note: The command is skipped if the `--skip-yarn` flag is used.
      
      Parameters
      ----------
      path: str, optional
          The base path of the node package.  Defaults to the repo root.
      build_dir: str, optional
          The target build directory.  If this and source_dir are given,
          the JavaScript will only be build if necessary.
      source_dir: str, optional
          The source code directory.
      build_cmd: str, optional
          The yarn command to build assets to the build_dir.