GoogleContainerTools/skaffold

How to sync node_modules

Open

#5,029 opened on Nov 14, 2020

View on GitHub
 (5 comments) (1 reaction) (0 assignees)Go (1,416 forks)batch import
area/synchelp wantedkind/feature-requestpriority/p3

Repository metrics

Stars
 (12,822 stars)
PR merge metrics
 (Avg merge 3d 6h) (16 merged PRs in 30d)

Description

Sometimes I need to link an npm package for developing multiple packages that depend on each other locally. (https://docs.npmjs.com/cli/v6/commands/npm-link)

I can't seem to get file sync to work with node_modules updates from package symlinks. I can confirm that the files in node_modules are updating but they are not being synced. I think it excludes node_modules initially using .dockerignore. If I exclude the scoped packages from the dockerignore (!node_modules/@scope) it then struggles to build the image because of a mkdir -p node_modules/@scope/package "already exists" error. If I rm -rf node_modules/@scope after installing for the image, the node_modules/@scope directory never seems to get built.

I have tried

    sync:
      infer:
      - '**/*.ts'
      # with this for node_modules/@scope/package/dist/file.js
      - '**/*.js'
      # or
      - 'node_modules/**/*.js'

Dockerfile

FROM node:14.15.0-alpine as base
WORKDIR /cache
COPY package.json .
COPY yarn.lock .
COPY .npmrc .
RUN yarn

FROM base as build
WORKDIR /app
COPY . ./
COPY --from=base /cache/node_modules /app/node_modules
EXPOSE 3000
CMD ["yarn", "start:dev"]

Contributor guide