Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,63 @@ $ npm -v

* **Question:** What is the difference between forking and cloning a repository as opposed to just cloning a repository?

* **Your Answer:**
* **Your Answer:** Fork copies to your own repo in Git. Clone creating a local copy on your dev side.

---

- [ ] Run `npm init -y` from the command line

* **Question:** What does `npm init` do? How does the `-y` flag modify that command?

* **Your Answer:**
* **Your Answer:** npm init creates the structure of the project. -y is going to accept defaults, and use "yes".

---

- [ ] Take a look at the file that was generated by the previous command

* **Question:** What is the purpose of the following keys? "name", "scripts", "license"

* **Your Answer:**
* **Your Answer:** name - project name. scripts - what is going to be called. license - licenses you have used in your project.

---

- [ ] Create a `.gitignore` file

* **Question:** What is the purpose of the `.gitignore` file? What is the significance of a "dot-file?"

* **Your Answer:**
* **Your Answer:** Files you do not want tracked by Git.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, more broadly, a "dot-file" is typically a hidden file.


---

- [ ] Create an `index.js` file with the following contents: `console.log('Hello, Node!')`

* **Question:** From the command line, how can you run this file?

* **Your Answer:**
* **Your Answer:** npm index.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll actually be node index.js. node is the program that allows to run JavaScript on our machine. npm is a package manager and gives us access to packages and scripts, among other things.


---

- [ ] Run `npm test` from the command line

* **Question:** What happens and how is this related to what is in the `package.json` file?

* **Your Answer:**
* **Your Answer:** It looks in the package.json and executes what is defined in the test script.

---

- [ ] Create a new "script" command called "start" that has the following value: `node index.js`

* **Question:** What will you enter on the command line to run that script?

* **Your Answer:**
* **Your Answer:** node index.js start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be npm start.


---

- [ ] Change the name of your "start" script to "my-file"

* **Question:** The same pattern will not work to try and run this script. How can you successfully get this script to run?

* **Your Answer:**
* **Your Answer:** node index.js my-file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be npm run my-file.


---

Expand All @@ -111,19 +111,19 @@ $ npm -v

* **Question:** What gets logged? Why?

* **Your Answer:**
* **Your Answer:** My name / age I added to the log portion of index.js.

* **Question:** What is `module.exports` and what is its _type_ in JavaScript? What is `require` and what is its _type_ in JavaScript?

* **Your Answer:**
* **Your Answer:** module.exports is a special object that is exposed as a module. require is a built in function.

---

- [ ] We can only export one thing from files when using Node. With that said, export both your name and your birthday from the `profile.js` file.

* **Question:** What are some ways you can solve this problem?

* **Your Answer:**
* **Your Answer:** You can use an array to export more than one value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An array or an object. Objects are more typical.


---

Expand All @@ -135,23 +135,23 @@ $ npm -v

* **Question:** What is `path` and where does it come from?

* **Your Answer:**
* **Your Answer:** Path is a module we import and is installed by NPM.

---

- [ ] Install the [moment](https://www.npmjs.com/package/moment) package

* **Question:** What command can you run to install this package?

* **Your Answer:**
* **Your Answer:** npm install package_name

---

- [ ] On your own, use this package in the `index.js` file

* **Question:** Do you need to use a `./` to require the package? Why or why not?

* **Your Answer:**
* **Your Answer:** ./ lets node know to look in the same realitive path it is running inside of.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and in this case we are not looking for a relative file path but instead an installed module. In that case, we'll look inside of node_modules/.


---

Expand All @@ -160,4 +160,4 @@ $ npm -v
#### Resources

- [Node.js Built-In Modules](https://nodejs.org/dist/latest-v12.x/docs/api/)
- [NPM: Moment](https://www.npmjs.com/package/moment)
- [NPM: Moment](https://www.npmjs.com/package/moment)