No, doing npm install in a different container and copying over the result.
Docker has multi-stage build, which allows using a container to build and copying over in a different result container..
I suspect this could be relevant many place, keeping images small also hardens security.