Npm scripts are commonly used by developers and infrastructures to automatically install dependencies and run tests. In this tutorial, Alex Banks will explore how to define scripts in the package.json file, and demonstrate how to run custom scripts to automate, test, and debug your application.
- View Offline
- Exercise Files
- Npm also provides us a way…to automate running, testing, debugging our applications…or, really, running any Unix or DOS commands.…A few of these scripts are quite important…because they are commonly used…by developers in infrastructure tools…to automatically install dependencies,…run tests, or even start our app.…And in this package JSON file,…on line six, we have a scripts node.…Now, there's just a "test" script in there,…and it says, "echo no test specified."…What I'm going to do is I'm going to delete this "test" node…and we are going to add a script for starting our website.…
"Npm start" is a script that we're going to be able to run…that will actually start our web application.…What we need to do is, in the package JSON,…under "scripts," define how to start the site.…So we actually start this site by running "node app,"…so that will start the site.…Now, every script has a pre-script and a post-script,…so, realistically, when we start our site,…we want to make sure that "grunt" runs…to generate all of the client files.…
Alex Banks shows how to install Node.js on a Mac or PC and work with the Node.js core: the global object, event loop, http module, and file system. Then he covers reading and writing data, streaming data, making http requests, and working with the node package manager (npm). In the final chapters, he shows how to start sessions on web servers, communicate with web servers and clients with WebSockets, use the Express framework to develop applications, and test and debug Node.js code. Want to speed up your Node.js workflow? Check out the tutorials on automating tasks with Grunt and npm scripts.
- What is Node.js?
- Installing Node.js
- Understanding the global object and global timing
- Importing the core modules
- Handling events
- Creating child processes
- Reading, writing, and removing files
- Working with file streams
- Making http requests
- Serving files and JSON data
- Installing npm, the node package manager
- Working with Express, the web server framework
- Using WebSockets
- Testing and debugging Node.js code
- Working with Grunt and Browserify
- Automating tasks with npm scripts
Skill Level Intermediate
1. What Is Node.js?
2. Installing Node.js
3. Node Core
4. Node Modules
5. The File System
6. The HTTP Module
7. Node Package Manager
Installing npms locally4m 4s
8. Web Servers
Creating a WebSocket server8m 30s
10. Testing and Debugging
11. Automation and Deployment
Next steps2m 4s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.