Installing dependencies with npm and package.json

As we have explained, if you have package.json, then you can define both dependencies and devDependencies. Here's an example:

{   "name": "npm-install-example",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "echo \"Error: no test specified\" && exit 1"   },   "author": "dSebastien <seb@dsebastien.net>    (https://www.dsebastien.net)",   "dependencies": {     "lodash": "4.17.11"   },   "devDependencies": {     "karma": "3.0.0"   } } 

In this example, we have defined the dependencies section and we have added a dependency in relation to the 4.17.11 version of the lodash (https://lodash.com) library. In devDependencies, we have defined a dependency in relation to the ...

Get Learn TypeScript 3 by Building Web Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.