Closed ejayesh closed 2 months ago
I have managed to resolve the issue. node_modules is not created or possibly removed when you do not specify in package.json npm install somewhere in the scripts section. eg. "scripts": { "build": "npm install" }
On previous releases of npm-install or with other buildpack this was not required.
This seems very suspect. Can you provide us with some more details on what kind of app this is? What langauge-family buildpack you are using (Node.js? Web Servers?)? It might be very helpful to include examples of package.json
files that don't work correctly.
We are migrating from Cloud Foundry onto AWS ECS so we are using Paketo to build OCIs that we can deploy. The Source code in question is here: https://github.com/uktrade/return-to-office/blob/master/package.json
This is a Django app, that takes care of the Web server, as per Procfile. We run the following pack command.
pack build ${DOCKERREG}/${APP_NAME} \ --tag ${DOCKERREG}${APP_NAME}:${GIT_TAG} \ --builder paketobuildpacks/builder:0.2.263-full \ --buildpack python --buildpack nodejs
This is what pack detects.
[detector] 9 of 15 buildpacks participating [detector] paketo-buildpacks/ca-certificates 3.5.1 [detector] paketo-buildpacks/cpython 1.8.4 [detector] paketo-buildpacks/pip 0.16.4 [detector] paketo-buildpacks/pip-install 0.5.9 [detector] paketo-buildpacks/python-start 0.14.3 [detector] paketo-buildpacks/procfile 5.5.0 [detector] paketo-buildpacks/node-engine 1.2.1 [detector] paketo-buildpacks/npm-install 1.0.3 [detector] paketo-buildpacks/node-run-script 1.0.2
Thanks. fyi, I resolved this issue by updating package.json as per this. https://github.com/uktrade/return-to-office/blob/copilot/package.json
The issue is that you are using a Procfile
. No buildpack is requesting "node_modules" to be present at run time. npm-start
would do so, but you do not have a start
script defined in your package.json
. If you would add
"scripts": {
"start": "./scripts/entry.sh"
}
and get rid of the Procfile
the node_modules
would be present at runtime.
@ejayesh Your workaround works of course as well, but you are installing "node_modules" twice. Is there a reason why you *need a Procfile
?
@ejayesh looks like @c0d1ngm0nk3y answered your question. Is this still an issue for you or can the issue be closed?
It look like this was answered...
The latest npm_install buildpack is removing the /tmp/node_modules directory after build. Older buildpacks eg 0.7.1 used the directory /layers/paketo-buildpacks_npm-install/modules/node_modules, which persisted.
Expected Behavior
/tmp/node_modules should exist
Current Behavior
/tmp/node_modules is being removed
Possible Solution
No need to remove it or just store node_modules elsewhere.
Steps to Reproduce
Motivations
Our application is looking for packages that are installed in the /workspace/node_module directory during run time. Not having this here is caused the application to fail. Other npm-install buildpacks (eg Heroku, cloud-foundry) do not remove this directory and I can see from your older release (0.7.1) that this was not removed. Can this behaviour be reverted back? Or at least have an option to not remove that directory.