paketo-buildpacks / npm-install

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

Subsequent Builds Fail When A Local Dependency Is Used #765

Open tuckeremulls opened 2 months ago

tuckeremulls commented 2 months ago

Expected Behavior

Projects with local dependencies should have successful builds every time.

Current Behavior

When using a local stylesheet dependency within the project, the first build succeeds, but subsequent builds fail. This seems to be because in subsequent builds, the cached /layers/paketo-buildpacks_npm-install/build-modules layer is reused and somehow the local dependency is then unable to be found.

Project structure:

package.json:

{
    ...
    "dependencies": {
        ...
        "@somedependency/prebuilt-themes": "file:./dependencies/@somedependency/prebuilt-themes",
        "@somedependency/shell": "file:./dependencies/@somedependency/shell",
        ...
    }
}

First build is successful, no layer is cached, and all dependencies are installed screenshot:

Screenshot 2024-09-10 155455

Screenshot 2024-09-10 155744

Subsequent builds fail. Subsequent builds use the cached npm-install layer and fail during the Node Run Script buildpack layer, screenshot:

Screenshot 2024-09-10 165154

The specific error is as follows:

Error: Module build failed (from ../layers/paketo-buildpacks_npm-install/build-modules/node_modules/mini-css-extract-plugin/dist/loader.js): HookWebpackError: Module build failed (from ../layers/paketo-buildpacks_npm-install/build-modules/node_modules/sass-loader/dist/cjs.js): SassError: Can't find stylesheet to import.

Possible Solution

Steps to Reproduce

Using kpack. Paketo NPM Install 1.4.10 Paketo Node Run Script 1.0.27

Motivations

This prevents our deployments from succeeding. We have to delete our kpack image object and recreate it every time so the npm-install layer won't be cached and the build will succeed.