Evolving and testing code running in a container
Make sure you have Node.js and npm
installed on your computer before you continue. On Mac, use this command:
$ brew install node
On Windows, use the following command:
$ choco install -y nodejs
When developing code that will eventually be running in a container, the best approach is often to run the code in the container from the very beginning, to make sure there will be no surprises. But we have to do this in the right way so that we don’t introduce any unnecessary friction to our development process. First, let’s look at a naïve way we could run and test code in a container. We can do this using a basic Node.js sample application:
- Create a new project folder and navigate to it:
$ mkdir node-sample && cd node-sample
- Let’s use
npm
to create a new Node.js project:$ npm init
- Accept all the defaults. Notice that a
package.json
file is created with the following content:
...