I want to use Docker to create development environments for a simple node.js. project. I would like to install the project dependencies (they are all npm packages) inside the docker container (so they will not touch my host) and still mount my code using the volume. Thus, the container should be able to find the folder node_modulesin the path where I will mount the volume, but I should not see it from the host.
This is my Docker file:
FROM node:6
RUN mkdir /code
COPY package.json /code/package.json
WORKDIR /code
RUN npm install
This is how I run it:
docker build --tag my-dev-env .
docker run --rm --interactive --tty --volume $(pwd):/code my-dev-env npm test
And this is my .json package:
{
"private": true,
"name": "my-project",
"version": "0.0.0",
"description": "My project",
"scripts": {
"test": "jasmine"
},
"devDependencies": {
"jasmine": "2.4"
},
"license": "MIT"
}
It fails because it cannot find jasmine, therefore it does not install it:
> jasmine
sh: 1: jasmine: not found
Can I do something with Docker? An alternative could be installing packages around the world. I also tried to npm install -gno avail.
Debian Docker 1.12.1, build 23cf638.