Skip to content

Commit 66f816d

Browse files
author
Ryan Kotzen
committed
Updating npm section
1 parent b0e3a7d commit 66f816d

File tree

6 files changed

+243
-113
lines changed

6 files changed

+243
-113
lines changed

.idea/workspace.xml

+115-104
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.npmrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
save=false
2-
save-exact=false
1+
#save=false
2+
#save-exact=false

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ A repository for my Beer & Technology talk on MongoDB and Node.js
1414
* http://www.mongodb-is-web-scale.com/
1515

1616
#TODO
17-
* npm global modules
18-
* npm scripts
19-
* MongoDB
20-
* MongoChef
17+
2118
* eslint
2219
* testing (mocking, async vs sync)
20+
21+
* MongoDB
22+
* MongoChef
23+
2324
* How to deal with async callback hell (Promise, Async.js, async/await co/generator functions)
25+
2426
* Express
2527
- Error handling
2628
- Logging
27-
* PM2
29+
* PM2
30+
* Electron
31+
* React-Native?

node/2-npm/README.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,45 @@ Note that you can also install multiple dependencies at the same time. E.g.:
7070
This is all good and well, but how do I use a dependency once it has been installed?
7171
See index.js
7272

73-
#Shrinkwrap - make mine to go!
73+
# Shrinkwrap - make mine to go!
7474

7575
Once you are ready to deploy your app type `npm shrinkwrap` and this will freeze all of your dependencies, and their dependencies, and their dependencies, and their dependencies, etc and write it to the `npm-shrinkwrap.json` file in the root of your app. When your server hosting node does a `npm install`, this file will be used to install the exact dependencies you had on your dev/ci/cd box.
76+
77+
# Global modules
78+
79+
Add the -g flag e.g. `npm i loadtest -g`. Often times this will add a new .cmd or bash command, hence why it should be in your path variables.
80+
81+
These get installed to `%USERPROFILE%\AppData\Roaming\npm`
82+
83+
Often an anti-pattern so ensure you are using this correctly.
84+
85+
# Dev Dependencies
86+
87+
Add the --save-dev flag e.g. `npm i mocha --save-dev`. This is for the packages you use during dev/ci/cd but which do not get installed to production. Examples include linting and testing.
88+
89+
# Scripts
90+
91+
`npm run <nameOfScript>` - Runs a script defined in your package.json. No need for gulp/grunt! Often used to kick off testing/linting etc.
92+
93+
`package.json`:
94+
95+
```
96+
{
97+
...
98+
"scripts":{
99+
...
100+
"lint": "node_modules/.bin/eslint \"src/**/*.js\" \"test/**/*.js\" index.js --fix"
101+
}
102+
}
103+
```
104+
105+
> `npm run lint`
106+
107+
# Extra commands
108+
109+
* `npm outdated` - list outdated packages.
110+
* `npm update` - Update packages, see the `npm-check` package.
111+
* `npm dedupe` - Removes duplicate packages from the node-modules folder based on wildcards. See https://docs.npmjs.com/cli/dedupe.
112+
* `npm link` - Used for modules development, allows you to link a specific module to a folder on your pc.
113+
* `npm prune --production` - Removes dev dependencies.
114+
* `npm t` | `npm test` - Runs the test command specified in your scripts of your package.json.

npm-shrinkwrap.json

+75
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "./node/1-hello-world/index.js",
66
"dependencies": {
77
"edge": "6.5.1",
8-
"moment": "2.18.1"
8+
"moment": "2.18.1",
9+
"mongodb": "2.2.25"
910
},
1011
"devDependencies": {},
1112
"scripts": {

0 commit comments

Comments
 (0)