Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
console.log('Hello, Node!')

const profile = require('./src/profile.js')
console.log(profile)

const path = require('path')
console.log(path.resolve())

const moment = require('moment')
console.log(moment().format("dddd, MMMM Do YYYY, h:mm:ss a"))
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "w1-node-ecosystem",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"moment": "^2.24.0"
}
}
31 changes: 17 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ $ npm -v

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

* **Your Answer:**
* **Your Answer:** Forking allows me to create a duplicate project in my own (eg. Github) space where I control the permissions. Simply cloning another person's project may not allow me to push my changes back to the origin.

---

- [ ] 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:** Creates the nessecary setup for a node project, namely the package.json file. -y accepts all the defaults without interaction.

---

Expand All @@ -55,46 +55,49 @@ $ npm -v
* **Question:** What is the purpose of the following keys? "name", "scripts", "license"

* **Your Answer:**
** name: required; if your project becomes the dependency of another project it will be called by "name"
** scripts: scripts that can be run on the project with the npm command. This can be important if your code is deployed, for example a CI/CD pipeline needs to know how to run your tests, and a hosting site needs to know how to run your code.
** license: any restrictions you have on the use of your code goes here. There are some standard, particularly open source licenses that you can use, or you can create a custom license.

---

- [ ] 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:** dot files don't show up under ls, and are normally used for settings. .gitignore lists file or path patterns of files that will not be committed to the repo. Examples are files that contain secrets, build files, and runtime files.

---

- [ ] 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:** node index.js

---

- [ ] 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:** "Error: no test specified" npm ERR! Test failed. The "test" script is run. If you have actual tests you should modify the test script to run them.

---

- [ ] 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:** 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:** npm run my-file. Start is a reserved word and takes no arguments (file name).

---

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

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

* **Your Answer:**
* **Your Answer:** My name. require imports the code from profile.js into the running process.

* **Question:** What is `module.exports` and what is its _type_ in JavaScript? What is `require` and what is its _type_ in JavaScript?
* **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 an object and makes the object accessible to other modules. require is a function, and is used to import other files or modules.

---

- [ ] 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:** Wrap multiple things into an object or array.

---

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

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

* **Your Answer:**
* **Your Answer:** A utility for working with file paths (directories). It is part of the default node package.

---

- [ ] 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 moment

---

- [ ] 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:** no. Only put ./ in front of files that are not imported into node_modules.

---

Expand Down
2 changes: 2 additions & 0 deletions src/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {'name': 'Michael Munsey', 'birthday': 'July 12'}