`npm: command not found`
Hello 👋 ,
Given a simple NodeJS project like this: node-example.zip
When you unzip it,
cd ./node-example and run pack build --builder heroku/builder:24 my-hello.
After the image is created, when you run the docker image, and go to the Docker bash terminal.
When I run npm run hello,
I expect the npm (and node) bin executables to be available in the $PATH
and to see the following output: Hello
The acutal behavior is that I see npm: command not found.
Although the build image does contain npm and node bins, they are not added to the $PATH,
When I paste export PATH=$PATH:/layers/heroku_nodejs-engine/dist/bin to the docker bash terminal, I will be able to run npm and node commands.
Is there something I am missing to configure in order to have npm and node without me having to do export PATH=$PATH:/layers/heroku_nodejs-engine/dist/bin
@predragnikolic Hi! I've transferred this issue to the Node.js CNB GitHub repo. The Node.js owner @colincasey will take a look at this at some point - though in the meantime I would suggest the first thing to try is that you are invoking a shell via the launcher (which depending on the buildpack setup might be the default if no process type is configured): https://buildpacks.io/docs/for-app-developers/how-to/build-outputs/specify-launch-process/
Thanks for the quick reply @edmorley.
When running docker run --rm --entrypoint launcher -it my-hello bash I am able to access npm and node from bash.
(I will probably write something that doesn't make sense, excuse me)
Is there a way to embed the entrypoint to the docker image itself, like have ENTRYPOINT ["launcher"] in the generated docerfile?
What I would like to achieve is to build a project with pack build my-hello --builder heroku/builder:24, start the image, open a terminal in the container and access npm and node commands without having to worry about --entrypoint launcher.
I am pretty sure it is possible, I just do not know the how part.
So I think the UX can be improved for the Node.js buildpack if it wraps the default process it sets with bash -c. Currently the Node.js buildpack does not do this:
https://github.com/search?q=repo%3Aheroku%2Fbuildpacks-nodejs%20process_type&type=code
Compare to what the Procfile CNB does (which is what gets used if an app has a Procfile, and will override the Node.js CNB's defaults):
https://github.com/heroku/buildpacks-procfile/blob/798f602616353c15d6068e4b8ab29d164fe8a1cf/src/launch.rs#L16-L20
And as I write this, I've just remembered this UX issue also came up here: https://github.com/heroku/buildpacks/discussions/15
cc @schneems
Hello, there is no need to rush, feel free to make the change when ever you feel like it.
I will close the issue, because I want to reduce the number of open issues I have. This "issue" is not really an issue for me.