Skip to main content
Skip table of contents

Yarn Workspace Utility Scripts

The following is a list of default scripts that have been set up in the worktree make maintaining your workspace easier.

Listing imports

list-imports:apps and list-imports:plat

These scripts are meant to be used as a guide; to give developers rough idea of which npm/workspace packages are used within a selected directory range. They work by performing a cursory scan for imported packages (thus path imports are not accounted for in the results) and returning an account  dependencies and devDependencies and ‘uninstalled’ packages,  in json format, for convenience. This is handy information to have when you are filling out dependencies in your project’s package.json file.

list-imports:apps [--app-folder <dir>]

Provides results for  ./src/applications

list-imports:plat [--app-folder <dir>]

Provides results for  ./src/platform

Example: yarn list-imports:apps --app-folder vaos


Analyzing app imports...
  dependencies: {
    react: '^17.0.2',
    moment: '~2.24.0',
    'react-router-dom': '^5.3.0',
    'react-redux': '^7.2.6',
    'prop-types': '^15.6.1',
    classnames: '^2.3.1',
    reselect: '^2.5.4',
    'history-v4': 'npm:history@4.9.0',
    redux: '^4.1.1',
    'redux-thunk': '^2.3.0'
  devDependencies: {
    '@sentry/browser': '^6.13.2',
    webpack: '^5.70.0',
    '@babel/parser': '^7.17.7',
    '@babel/traverse': '^7.17.3',
    glob: '^7.2.0',
    'append-query': '^2.1.1',
    mockdate: '^3.0.5',
    chai: '^4.3.4',
    '@testing-library/dom': '^7.26.6',
    '@testing-library/user-event': '^12.2.2',
    sinon: '^3.2.1',
    '@testing-library/react': '^11.1.2',
    'just-diff': '^3.1.1'
  uninstalled: {
    '@department-of-veterans-affairs/component-library/dist/react-bindings': 'uninstalled',
    'simple-guid': 'uninstalled',
    '@department-of-veterans-affairs/react-components/Breadcrumbs': 'uninstalled',
    '@department-of-veterans-affairs/react-jsonschema-form/lib/utils': 'uninstalled',
    '@department-of-veterans-affairs/component-library/ExpandingGroup': 'uninstalled',
    path: 'uninstalled',
    'jsdoc/util/doop': 'uninstalled',
    'jsdoc/fs': 'uninstalled',
    'jsdoc/util/templateHelper': 'uninstalled',
    'jsdoc/util/logger': 'uninstalled',
    'jsdoc/path': 'uninstalled',
    'jsdoc/template': 'uninstalled',
    util: 'uninstalled',
    fs: 'uninstalled',
    'mocker-api/lib/delay': 'uninstalled'

From the above results, you can gleam that the moment package is imported at least once in the vaos app, that moment is actually already installed at the root of the repo, and that the versioning, for this package, at the root of the repo is ‘~2.24.0'. A team could then use this info in their app’s package.json dependencies field: listing the same (or different, if needed) versioning.or choosing to use peerDepencies and "moment":"*" to automatically use whichever version of moment is installed in the main repo.

Reminder: You must have a root level node_modules folder present for this script to run successfully. If you have deleted node_modules at the root level or you have not yet done an install at all, run yarn install prior to running this script

Deleting node_modules Folders


Deletes node_modules folder(s) and its contents without uninstalling the modules from the package.json file. This useful if you need to run yarn install from a clean slate. 

To run, use the command: yarn modules-folder:del [options] and answer 'y'  on the confirm prompt. You will receive confirmation of deletion or cancelation.

When deleting files, the script may take a few seconds to run. Please be patient.


Deletes all node_modules from the root of the mono repo down

. Deletes all node_modules folders from the present working directory down

/ Deletes all node_modules folders under node_modules

my/path Deletes all "node_modules" folders under ./src/my/path

Example: yarn modules-folder:del  

Will delete ALL the  node_modules folders  within the repo

Example: yarn modules-folder:del applications/vaos  

Will delete ONLY the  node_modules folder for the vaos app, located in ./src/applications/vaos

Workspace demo


This script is optionally set up by the Release Tool Team, and may not be present in your workspace! It is/was supposed to serve as one of the ways to tell that your code is within a functional Yarn Workspace. It is a simple ‘hello world’ script, but it serves as a useful demonstration of a workspace-level script.

To run, use the command:  yarn workspace <your-workspace-name> run demo

Example: yarn workspace vaos run demo

The command will output a string to the console. Something similar to:

DEMOING @department-of-veterans-affairs/applications-vaos v 1.0.0 with WORKSPACE

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.