Updating the Detect Script
The detect script now sets a default Node.js version and then attempts to extract the user-specified version from the package.json file by reading the “engines.node” property. Finally, it writes the appropriate “provides” and “requires” fields to the buildpack build plan, which the build script uses later to download and install the correct Node.js version.Ensure that your package.json file contains the “engines” section with the correct Node.js version.
docker ps:
Updating the Build Script
Previously, the build script hardcoded Node.js version 18.18.1. In the updated script, a default Node.js version (18.18.0) is defined, and the desired version is later retrieved from the build plan. This retrieved version is then used to dynamically construct the download URL for the appropriate Node.js tarball. Below is the revised build script:Dynamically Constructing the Node.js Download URL
The build script is now updated to dynamically include the user-specified Node.js version. After retrieving the version from the build plan, the script prints the version for verification and constructs the download URL based on that version. The snippet below shows the modified section:Remember to delete the old container and rebuild the image to ensure the changes take effect.
Verifying the Buildpack with package.json
Once again, note that the version requested (as printed in the logs) is 18.18.0. The updated package.json looks like this:Additional Resources
For further details, visit the following helpful resources: