-
Notifications
You must be signed in to change notification settings - Fork 31
completed notes from class 1, node ecosystem #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
terishelton
wants to merge
1
commit into
pce-uw-jscript400:master
Choose a base branch
from
terishelton:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| 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()); | ||
| console.log(moment().format("ddd, hA")); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/terishelton/w1-node-ecosystem.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/terishelton/w1-node-ecosystem/issues" | ||
| }, | ||
| "homepage": "https://github.com/terishelton/w1-node-ecosystem#readme", | ||
| "dependencies": { | ||
| "moment": "^2.24.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,71 +34,71 @@ $ npm -v | |
|
|
||
| ### Instructions & Guiding Questions | ||
|
|
||
| - [ ] Fork & Clone this repository | ||
| - [x] Fork & Clone this repository | ||
|
|
||
| * **Question:** What is the difference between forking and cloning a repository as opposed to just cloning a repository? | ||
|
|
||
| * **Your Answer:** | ||
| * **Your Answer:** When you fork a repository, it copies the repository to your GitHub account, you clone from your account, and you can work on it from there. You can then submit a pull request when you're done to possibly have it merged into the master. With a clone from the master, you do not have a connection in your GitHub account to the original, it's just a copy. You can't submit a pull request later on. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Run `npm init -y` from the command line | ||
| - [x] 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 initializes the package.json file - walking you through a wizard of questions to fill it out. The -y flag creates a package.json file with default info. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Take a look at the file that was generated by the previous command | ||
| - [x] 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 app, scripts are scripts you can run with npm or node (start, test, build, etc.), license is the license you want to offer your app under. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Create a `.gitignore` file | ||
| - [x] 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:** A .gitignore file is to tell git what to include and not include in the repository. A dot-file is a "hidden" file. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Create an `index.js` file with the following contents: `console.log('Hello, Node!')` | ||
| - [x] 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 | ||
| - [x] 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 gives an error because no test has been specified. It prints out exactly what is in the package.json file for test. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Create a new "script" command called "start" that has the following value: `node index.js` | ||
| - [x] 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" | ||
| - [x] 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 | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Create a new file called `profile.js`. Inside the file, copy the following but replace `<your-name>` with your name: | ||
| - [x] Create a new file called `profile.js`. Inside the file, copy the following but replace `<your-name>` with your name: | ||
| ```js | ||
| module.exports = '<your-name>' | ||
| ``` | ||
|
|
@@ -111,51 +111,51 @@ $ npm -v | |
|
|
||
| * **Question:** What gets logged? Why? | ||
|
|
||
| * **Your Answer:** | ||
| * **Your Answer:** 'Teri' is logged. Because index.js is importing it from profile.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 exports modules from a file so you can import it in another. It's an object. Require imports the module. Its type is 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. | ||
| - [x] 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:** convert it to an object or an array instead of a string. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Add the following to your `index.js` file. Then, run your file. | ||
| - [x] Add the following to your `index.js` file. Then, run your file. | ||
| ```js | ||
| const path = require('path') | ||
| console.log(path.resolve()) | ||
| ``` | ||
|
|
||
| * **Question:** What is `path` and where does it come from? | ||
|
|
||
| * **Your Answer:** | ||
| * **Your Answer:** Path is the full path to the file on your system. It's a built-in module. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be more specific, |
||
|
|
||
| --- | ||
|
|
||
| - [ ] Install the [moment](https://www.npmjs.com/package/moment) package | ||
| - [x] 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 | ||
| - [x] 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, because it's a package, not a file. | ||
|
|
||
| --- | ||
|
|
||
| - [ ] Move your `profile.js` file into a `src/` folder. Update the path in your `index.js` file to ensure everything continues to work. | ||
| - [x] Move your `profile.js` file into a `src/` folder. Update the path in your `index.js` file to ensure everything continues to work. | ||
|
|
||
| #### Resources | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module.exports = { | ||
| 'name': 'Teri', | ||
| 'birthday': '10/7' | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually can submit a pull request whether your Fork & Clone or just Clone!