cloudfoundry / nodejs-buildpack

Cloud Foundry buildpack for Node.js
http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
170 stars 384 forks source link

Build pack fails on installing any new modules #687

Closed gavintoddchurch closed 8 months ago

gavintoddchurch commented 9 months ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version? cf version 8.7.4+db5d612.2023-10-20

What version of the buildpack you are using? 1.8.11

If you were attempting to accomplish a task, what was it you were attempting to do? We were attempting to use the nodejs_buildpack on a project that has vendored its node_modules and that uses a private npm registry that requires authentication.

What did you expect to happen? When we do our cf push we have node_modules, package.json, package-lock.json in the context path We expected the app to push to CF without needing to download any dependencies

What was the actual behavior? We get a 401 error when it is trying to download dependencies that require auth

   -----> Building dependencies
   Prebuild detected (node_modules already exists)
   Rebuilding any native modules
   rebuilt dependencies successfully
   Installing any new modules (package.json + package-lock.json)
   npm ERR! code E401
   npm ERR! Incorrect or missing password.
   npm ERR! If you were trying to login, change your password, create an
   npm ERR! authentication token or enable two-factor authentication then
   npm ERR! that means you likely typed your password in incorrectly.
   npm ERR! Please try again, or recover your password at:
   npm ERR!     https://www.npmjs.com/forgot
   npm ERR!
   npm ERR! If you were doing some other operation then your saved credentials are
   npm ERR! probably out of date. To correct this please try logging in again with:
   npm ERR!     npm login
   npm ERR! A complete log of this run can be found in: /home/vcap/.npm/_logs/2023-12-15T23_02_00_149Z-debug-0.log
   **ERROR** Unable to build dependencies: exit status 1
   Failed to compile droplet: Failed to run all supply scripts: exit status 14

Our current theory is our build process does an npm CI --omit=dev --omit=optional before we deploy to CF. The node_modules then doesn't contain all the devDependencies that are in the package-lock so it tries to reach out to the registry in our .npmrc and download the missing dependencies. Our registry requires auth so it fails to download the dependencies.

Can you provide a sample app? Not at this time but can look into it

Please confirm where necessary:

gavintoddchurch commented 9 months ago

I found a project that wasn't working and if i remove the dependency code-hike/mdx it then started working. Any advice on how to move past this would be greatly appreciated