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/
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// console.log('Hello, Node!')
//
const profile = require('./src/profile.js')
console.log(profile.name + " - " + profile.birthdate)
//
//
// const path = require('path')
// console.log(path)
// console.log(path.resolve())

//path.resolve() returns a string
//path is an object that has many functions

const moment = require('moment')
console.log(moment().format('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.

24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "w1-node-ecosystem",
"version": "1.0.0",
"description": "Welcome to JSCRIPT 400 - Server Side Development with JavaScript",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/delrosam/w1-node-ecosystem.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/delrosam/w1-node-ecosystem/issues"
},
"homepage": "https://github.com/delrosam/w1-node-ecosystem#readme",
"dependencies": {
"moment": "^2.24.0"
}
}
32 changes: 16 additions & 16 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:** forking a git repository copies copies the repo, including all previous commits to another account and maintains the connection to the original repo, whereas cloning simply copies the repository from the current state of the repository.

---

- [ ] 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` prompts you for values to put into the package.json file before it is created in your project folder. The `-y` flag simply creates the package.json for you with default values.

---

- [ ] 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` is the name of the project. `scripts` are all the commands that can be ran in terminal to do run, start, test and debug the project. `license` is where the type of license the project will have.

---

- [ ] 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:** `.gitignore` is a file that lists all other files or folders that you want git to ignore and not include in any of the commits. the dot makes the file hidden.

---

- [ ] 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?
* **Question:** What happens and how is this related to what is in the `package.json` file?

* **Your Answer:**
* **Your Answer:** we see an error when the command is run. the error message we see is the same message thats in the `package.json` file beside 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:** `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:** by running `npm run my-file`

---

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

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

* **Your Answer:**
* **Your Answer:** My name. Because my name is being exported out of the profile.js and imported using the function `require` inside the index.js file.

* **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. `require` is a function that is part of node.

---

- [ ] 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:** Placing both my name and birthday into an object and exporting that object.

---

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 that can help determine directories and file paths. It comes as a part of node.

---

- [ ] 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 --save`

---

- [ ] 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, you do not need to use `./` because its not a local file.

---

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)
6 changes: 6 additions & 0 deletions src/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var me = {
name: "Marnel Mangrubang",
birthdate: 'December 8'
}

module.exports = me;