Skip to content

lab 21 More Structure

Goals

Now add a package.json

This lab assumes you have installed node. Please do that before continuing.

Let’s add a package.json to the hello directory. The following one will do nicely.

package.json

{
  "name": "greeter",
  "version": "1.0.0",
  "description": "Greet users from the command line",
  "scripts": {
    "start": "node lib/start.js"
  }
}

Add and commit the change.

Execute:

git add package.json
git commit -m "Added a package.json."

You should be able to use npm to run your hello program now.

In order to run our program we will exit the simulation terminal. Close out the simulation, run the program, and then go back to the simulation

Execute:

- Press ctrl and C simultaneously to close the simulation

cd hello

npm start

Output:

$ npm start

> greeter@1.0.0 start /Users/opsparkowl/Documents/opspark/dev_shop/git-immersion/auto/hello
> node lib/start.js

Hello, World!

Go back to the terminal simulation

cd ..
npm start