4.2 Missing Exports
Notice the two different files:
Task:
Add the proper exports line to have a successful high five!
high_five.js ```js var highfive = function() { console.log("smack!!"); }; module.exports = highfive; ```
app.js ```js var highfive = require('./high_five.js'); highfive(); ```
4.3 Export A Function
Notice the
Task:
Move the
my_request.js ```js var http = require('http'); var myRequest = function(message) { var request = http.request('http://codeschool.com', function(response) { response.pipe(process.stdout, { end: false }); }); request.write(message); request.end(); }; module.exports = myRequest; ```
app.js ```js var myRequest = require('./my_request'); myRequest('Hello, this is dog.'); ```
4.4 Exporting An Object
The
Task 1:
In the
Task 2:
In the
Task 3:
In the
```js exports.info = function(message) { console.log("Info: " + message); }; exports.warn = function(message) { console.log("Warning: " + message); }; exports.error = function(message) { console.log("Error: " + message); }; ```
4.5 Installing Local Modules
Practice using ``` npm install underscore ```
4.6 Installing Global Modules
Now install the ``` npm install coffee-script -g ```
4.7 Dependency
Add two dependencies to our
Task 1:
Add the
Task 2:
Add the
``` { "name": "My Awesome Node App", "version": "1", "dependencies": { "connect": "2.1.1", "underscore": "1.3.3" } } ```
4.8 Semantic Versioning
We want to make sure we are always up-to-date with the most recent patch-level changes to our dependencies when we run
Task:
Update the
``` { "name": "My Awesome Node App", "version": "1", "dependencies": { "connect": "~2.1.1", "underscore": "~1.3.3" } } ```
沒有留言:
張貼留言