Debugging Node.js
Easier Development
NPM
- Node Package Manager
- Initialize the node project
- Add some extra features
npm init
Then it’ll create package.json file and you can edit the scripts section, which you can write on the command line instead of the actual command.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js",
"start-server": "node app.js"
}
You can put
>>> npm start
>>> npm run start-server
instead of
>>> node app.js
Installing 3rd Party Packages
Dependencies (3rd Party)
- express
- body-parser
These dependencies can be installed and managed via npm Repository.
npm install nodemon --save-dev
It indicates only using during development!! Then we change
"start" : "nodemon app.js"
This command won’t work in command line because it’ll look for nodemon globally but it works in the npm script since it will look for the local version of the package.
Types of Errors
- Syntax Errors
- Runtime Errors
- Logical Errors