TS2307: Cannot find module - install sub node_modules

So it is currently not recognizing any of the modules, and I think I know why, but, I don’t want to move forward with it and risk making more of a mess of it. I have a mono-repo that contains all of the sections of the project. So I have a folder structure that looks like this:

(root)
|-application
|-- app
|---- node_modules
|------package.json
|-server
|---- node_modules
|-----package.json
.gitignore
node_modules
tsconfig.json

This looks like a rats nest of overlapping package installs of jest, tsconfigs, etc. but the main issue here is that when circleci runs the tests, it is looking at the root level’s package.json instead of the application's node_modules.
so I think I need to tell CircleCI to go into each folder and install the dependencies in application and in server. How could I do that?

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:12.7.0
    working_directory: ~/repo
    steps:
      - checkout
      #download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: npm install
      - run: npm test

also, I have gone here and while I see that is about testing, could I do something similar with installing dependencies? Well, I will keep working on it and if I get it working I will post the answer

  • update1: I followed the advice on the link shared, however now the test section is being ignored and directly passed, looking at the workflow it goes to step 3) restoring the cache then step 4) saving the cache then immediately passing. below is the updated yaml with accordance to previous post
jobs:
  build:
    docker:
      - image: circleci/node:12.7.0
    working_directory: ~/repo
    steps:
      - checkout

      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
    test:
      override:
        - cd application/app; npm test
        - cd server/src/User-Server; npm test

thank you for any help