I\'m trying to build a docker image with a global install of firebase-tools and angular-cli. I\'m building the same image for two versions of node: 6.x (LTS bor
instead of forcing NPM's hand to install the package inside the container I bypassed this issue by mapping/referncing a host folder for the missing module this also prevents future headaches for when I replace the docker image with the latest version, I won't have to repeat the stages to reinstall the missing module inside the container:
the steps i took:
create an empty folder on the host environment (will be used as a target for the node js modules). call it node_modules
when launching running the docker container use the --volume and --env switches
-- volume to pass map the new host folder (from step 1) to a folder accessible inside docker
--env to define/set an environment variable NPM_CONFIG_PREFIX from inside the docker to the /node_modules folder we created in step 1
access the container using :
sudo docker exec -i -t sh
and go to the folder above the folder right above the local /node_modules folder (this not the folder we mapped to the environment variable, but rather the preexisting folder that came with the docker image)
then run the command:
> npm install -g
example
> npm install -g request
this will install the module in the host folder we've created. this module will also be accessible from both docker and host.