Sunday, 3 May 2020

Node_modules and editing local files

In order to map the local host files to the container working directory, you need to have the node_modules directory locally. Otherwise, the modules "Cannot be found".


With your new package.json file, run npm install. If you are using npm version 5 or later, this will generate a package-lock.json file which will be copied to your Docker image.

Since "npm install" is not possible without installing nodejs (that's why I user docker!), you have to run npm install inside a container which maps the local files.(/home/ec2-user/teams/node:/hasapian)
This could be run by running docker-compose without a volume at first of by building a node image.

Then add the volume above in the docker-compose.yaml and you are good to go!

Module versions:
https://semver.npmjs.com/

No comments:

Post a Comment