paketo-buildpacks / npm-install

A Cloud Native Buildpack for npm
Apache License 2.0
10 stars 17 forks source link

build fails when using npm workspaces #712

Closed corey-aloia closed 2 months ago

corey-aloia commented 5 months ago

Expected Behavior

Paketo does not seem to work with node workspaces. If I remove the workspace from my package.json, then it builds successfully.

  Executing launch environment install process
    Running 'npm ci --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache'

      added 104 packages, and audited 106 packages in 9s

      14 packages are looking for funding
        run `npm fund` for details

      found 0 vulnerabilities
failed to copy linked module directory to layer path: stat /workspace/app/incidents: no such file or directory

This looks very similar to this closed ticket here: https://github.com/paketo-buildpacks/npm-install/issues/498

I wasted a silly amount of time on this. I thought I had done something wrong, as I knew it had worked before. I ended up creating a whole new app, and by trial and error, found that be removing "workspaces" it will work.

  "workspaces": [
    "app/*"
  ],

The reason I assumed it was my fault, is because SAP has this buildpack in their official instructions. And setting up these workspaces is also done by default via the tools used. So really surprising that it just doesn't work.

For reference, I set up a new demo app, and build via:

pack build $CONTAINER_REGISTRY/incident-management-srv:1.3 \
    --path gen/srv \
    --builder paketobuildpacks/builder-jammy-base \
    --publish
c0d1ngm0nk3y commented 3 months ago

Sorry for the delay @corey-aloia

I could not reproduce this problem and workspaces are working in general. There are some integration tests for this (e.g. here)

Given your input

"workspaces": [
    "app/*"
  ],

You have a folder called app with some subdirectories in it with are the workspaces, right? Does each of them has a package.json like described here?

Any change you still have code and can give us the structure (e.g. calling the tree command)?

mhdawson commented 2 months ago

Since there has been no response from the original poster after the response from @c0d1ngm0nk3y, and @c0d1ngm0nk3y seems not to be able to reproduce I'm going to go ahead and close.

Please let us know if that was not the right thing to do.