-
Notifications
You must be signed in to change notification settings - Fork 31
Readme in-class notes #12
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| console.log('Hello, Node!') | ||
| const profile = require('./src/profile.js') | ||
| console.log(profile); | ||
|
|
||
| const path = require('path') | ||
| console.log(path.resolve()) | ||
|
|
||
| const momentName = require('moment') | ||
| console.log(momentName().format('MMMM Do YYYY, h:mm:ss a')) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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 \"Hi Friends\" && exit 1", | ||
| "start": "node index.js" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/katrinagd/w1-node-ecosystem.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/katrinagd/w1-node-ecosystem/issues" | ||
| }, | ||
| "homepage": "https://github.com/katrinagd/w1-node-ecosystem#readme", | ||
| "dependencies": { | ||
| "moment": "^2.24.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,65 +38,49 @@ $ npm -v | |
|
|
||
| * **Question:** What is the difference between forking and cloning a repository as opposed to just cloning a repository? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| --- | ||
| * **Your Answer:** A fork is a copy of a repository that allows you to experiment with changes without affecting the original project. Cloning makes a local repo that is not connected to the original repo. | ||
|
|
||
| - [ ] 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:** Create a package.json file. -y generate it without having it ask any questions. | ||
|
|
||
| - [ ] 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 folder. 'Scripts' - a list of various commands like npm start, npm stop, npm restart etc. 'License' - an open source license you might be using. | ||
|
|
||
| - [ ] 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 dot file indicates a hidden file. A .gitignore file is where you list any other files you want gut to ignore (large files, API key) | ||
|
|
||
| - [ ] 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:** Will run tests specified in the scripts section in the package.json file. We get an error as per file. | ||
|
|
||
| - [ ] 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 | ||
|
|
||
| - [ ] Create a new file called `profile.js`. Inside the file, copy the following but replace `<your-name>` with your name: | ||
| ```js | ||
|
|
@@ -111,21 +95,20 @@ $ npm -v | |
|
|
||
| * **Question:** What gets logged? Why? | ||
|
|
||
| * **Your Answer:** | ||
| * **Your Answer:** | ||
| Hello, Node! | ||
| Katrina | ||
| As per 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` is an object (exported from profile.js). `require` is a 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:** Create an array. | ||
|
|
||
| - [ ] Add the following to your `index.js` file. Then, run your file. | ||
| ```js | ||
|
|
@@ -135,25 +118,19 @@ $ npm -v | |
|
|
||
| * **Question:** What is `path` and where does it come from? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| --- | ||
| * **Your Answer:** It's the path/folder structure of the file. It comes from the node module by default. | ||
|
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. Strictly speaking this is not right. |
||
|
|
||
| - [ ] 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, it is in the `node_modules` folder | ||
|
|
||
| - [ ] Move your `profile.js` file into a `src/` folder. Update the path in your `index.js` file to ensure everything continues to work. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| const name = 'Katrina' | ||
| const age = '39' | ||
|
|
||
| module.exports = { | ||
| name, | ||
| age | ||
| } |
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.
Small point of clarification: cloning makes a local repo that is connected to the repo that you cloned from. When you fork and then clone, you end up with a local version of the repo that is not connected to the original.