-1

I'm wondering where npm ci saves the node_modules.

Furthermore I want to zip the node_modules. Is this even possible with git workflows or should I try a different approach? I need this workflow to deploy the codebase on git to a lamda function in AWS.

This is my code for example:

jobs:
  node:
    runs-on: ubuntu-latest
    steps:
      - name:  Checkout
        uses: actions/checkout@v3
      
      - name:  Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16.13.2
          registry-url: 'https://npm.pkg.github.com'
          cache: 'npm'
          cache-dependency-path: '**/package.json'
          
      - name: Cache
        id: cache-dep
        uses: actions/cache@v3
        with:
          path: |
            ./node_modules
          key: ${{ runner.os }}-pricing-scraper-${{ hashFiles('package.json') }}
          restore-keys: |
            ${{ runner.os }}-pricing-scraper-
            
      - name: Config NPM
        shell: bash
        run: |
          npm install -g npm@8.1.2
          
      - name: ⚙️ Install node_modules
        if: steps.cache-dep.outputs.cache-hit != 'true'
        shell: bash
        run: |
          npm ci

  build:
    runs-on: ubuntu-latest
    needs: [node]
    steps:
      - name:  Checkout
        uses: actions/checkout@v3
      
      - name:  Zip files and folder
        if: steps.cache-dep.outputs.cache-hit != 'true'
        shell: bash
        run: |
          echo Start running the zip script
          # delete prior deployment zips
          DIR="./output"
          if [ ! -d "$DIR" ]; then
            echo "Error: ${DIR} not found. Can not continue."
            exit 1
          fi
          
          if [ ! -d "./node_modules" ]; then
            echo "Error: node_modules not found. Can not continue."
            exit 1
          fi
          
          rm "$DIR"/*
          echo Deleted prior deployment zips
          
          # Zip the core directories which are the same for every scraper.
          zip -r "$DIR"/core.zip config node_modules shipping util

          ...

It's not saved in the repo

- name: Bash Test node_modules
        if: steps.cache-dep.outputs.cache-hit != 'true'
        shell: bash
        run: |
          echo "cached"
          echo $(ls)

Output:

Run echo "cached"
cached
README.md build config output package-lock.json package.json scraper shipping testHandler.js util
Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • Please check this: https://stackoverflow.com/questions/52499617/what-is-the-difference-between-npm-install-and-npm-ci – Andrii Bodnar Dec 08 '22 at 09:21
  • Please do not add answers to the question body itself. Instead, you should add it as an answer. [Answering your own question is allowed and even encouraged](https://stackoverflow.com/help/self-answer). – Adriaan Dec 08 '22 at 13:27

1 Answers1

0

The place where the node_modules are stored is ´~/.npm´

The problem was that I did 2 jobs (node, build) on 2 different VMs. So the installed node_modules were on the other VM (node-job) than where I needed them (build-job).