Thursday, July 1, 2021

Angular

 1. node.js Active or Maintenance LTS is essential for angular, so install latest node Active or maintenance LTS.

2. Package.json contains scripts tag which are "run"nable npm scripts. You can directly run them using "npm run Script_key" 

"scripts": {

    "ng": "ng",

    "start": "ng serve",

    "build": "ng build",

    "watch": "ng build --watch --configuration development",

    "test": "ng test"

  },

In the above case,e.g., you can run  "npm run start" which is the same as running "ng serve".


You can also have pre and post commands : "prexx" : "UUUU" , "xx" : "VVVV" , "postxx" : "YYYY"

"npm run xx" will run the above three in that order.

3. Create a new app "ng new appname" : this creates a new app , creates package.json and makes a copy od node_modules directory. 

4.  npm init -y  => creates a package.json file with bare minimum default keys.

5. npm install xxx

or 

npm install xxx --save 

or npm i xxx -S

Installs the package XXX and adds a dependency under the section "dependencies"

 --save or -S can be ignored because it default. Earlier versions of npm did not make an entry in package.json by default, hence this option was there. 

Similarly, we can add the entry in "devDependencies" section, where the packages required only during development time are stored. 

npm install xxx --save-dev

npm i -D xxx


No comments:

Post a Comment

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...