|
| 1 | +# 2 - Dependencies |
| 2 | + |
| 3 | +Application's dependencies must be declared and isolated |
| 4 | + |
| 5 | +## What does that mean for our application ? |
| 6 | + |
| 7 | +Declaration are done in package.json file. |
| 8 | + |
| 9 | +Let's add sails-mongo (mongodb driver) as we'll need it very quicky |
| 10 | + |
| 11 | +`npm install sails-mongo --save` |
| 12 | + |
| 13 | +The package.json file should look like the following: |
| 14 | + |
| 15 | +``` |
| 16 | +{ |
| 17 | + "name": "messageApp", |
| 18 | + "private": true, |
| 19 | + "version": "0.0.0", |
| 20 | + "description": "a Sails application", |
| 21 | + "keywords": [], |
| 22 | + "dependencies": { |
| 23 | + "ejs": "2.3.4", |
| 24 | + "grunt": "0.4.5", |
| 25 | + "grunt-contrib-clean": "0.6.0", |
| 26 | + "grunt-contrib-coffee": "0.13.0", |
| 27 | + "grunt-contrib-concat": "0.5.1", |
| 28 | + "grunt-contrib-copy": "0.5.0", |
| 29 | + "grunt-contrib-cssmin": "0.9.0", |
| 30 | + "grunt-contrib-jst": "0.6.0", |
| 31 | + "grunt-contrib-less": "1.1.0", |
| 32 | + "grunt-contrib-uglify": "0.7.0", |
| 33 | + "grunt-contrib-watch": "0.5.3", |
| 34 | + "grunt-sails-linker": "~0.10.1", |
| 35 | + "grunt-sync": "0.2.4", |
| 36 | + "include-all": "~0.1.6", |
| 37 | + "rc": "1.0.1", |
| 38 | + "sails": "~0.12.3", |
| 39 | + "sails-disk": "~0.10.9", |
| 40 | + "sails-mongo": "^0.12.0" // Newly added dependency |
| 41 | + }, |
| 42 | + "scripts": { |
| 43 | + "debug": "node debug app.js", |
| 44 | + "start": "node app.js" |
| 45 | + }, |
| 46 | + "main": "app.js", |
| 47 | + "repository": { |
| 48 | + "type": "git", |
| 49 | + "url": "git://github.com/GITUSER/messageApp.git" |
| 50 | + }, |
| 51 | + "author": "AUTHOR", |
| 52 | + "license": "" |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +Dependencies are isolated within _node-modules_ folder where all the [npm](https://npmjs.org) libraries are compiled and installed. |
| 57 | + |
| 58 | +``` |
| 59 | +$ ls node_modules/ |
| 60 | +ejs grunt-contrib-coffee grunt-contrib-cssmin grunt-contrib-uglify grunt-sync sails |
| 61 | +grunt grunt-contrib-concat grunt-contrib-jst grunt-contrib-watch include-all sails-disk |
| 62 | +grunt-contrib-clean grunt-contrib-copy grunt-contrib-less grunt-sails-linker rc sails-mongo |
| 63 | +``` |
| 64 | + |
| 65 | +[Previous](01_codebase.md) - [Next](03_configuration.md) |
0 commit comments