Panicker February 2016

How to get all the dependencies using NPM for your Angular Application

i have installed NPM

also i had saved it as given in GITshowing the result after npm install

and i even installed gulp and when i checked its not been installedgulp error

**The template that i downloaded reads as follows : ** to automaticaly populate bower styles dependencies -->

<!-- build:css({.tmp/serve,src}) styles/app.css -->
<!-- inject:css -->
<!-- css files will be automaticaly insert here -->

in the body section :

<!-- build:js(src) scripts/vendor.js -->
<!-- bower:js -->
<!-- run `gulp wiredep` to automaticaly populate bower script dependencies -->
<!-- endbower -->
<!-- endbuild -->

<!-- build:js({.tmp/serve,.tmp/partials,src}) scripts/app.js -->
<!-- inject:js -->
<!-- js files will be automaticaly insert here -->
<!-- endinject -->

<!-- inject:partials -->
<!-- angular templates will be automatically converted in js and inserted here -->
<!-- endinject -->
<!-- endbuild -->

and finally i tried cashing everything i supposed to be relevant in my localhost but again it failed to run.

Answers


Raulucco February 2016

It seems like you forgot to initialize your working directory: npm init. Do the same for bower.

When you install a package with npm you can pass --save or --save-dev as parameters so npm will track the name and the version of the package in the package.json file.This allow to any one who clone your repo to run npm install and get all the packages been listed on the package.json file. If you want to use bower then you need to install it with npm install bower --save-dev and then install packages the same way as with npm. e.g: bower install jquery -S. So bower will track the dependencies of your project on a bower.json file. It is posible to add a preinstall and postinstall key on the scripts section of the package.json file so npm will run the those commands before of after installing your dependencies:

//package.json

{
  "scripts": {
    "postinstall": "bower install"
  }
}

To replace the scripts and links styles you'll need to create a task on your gulp file

Post Status

Asked in February 2016
Viewed 2,146 times
Voted 8
Answered 1 times

Search




Leave an answer