Initial environment setup:
nodejs 6.x version
The purpose of installing nodejs is to use npm to manage the packages of the project's dependent libraries
At this point use node --version , npm --version to confirm that it is installed correctly
Due to the network environment, cnpm ( preferred , maintained by Taobao team) and yarn can be used as alternative package management tools
Install cnpm: npm i -g cnpm
At this point, you can use cnpm instead of the npm installation command. For example: cnpm i -g @angualr/cli
Use cnpm i -g @angualr/[email protected] to install angular scaffolding. The cli tool can automatically build projects, modules, routes, etc.
The angular cli tool can make us ignore the configuration of the project structure, so that we can focus more on the writing of project functions.
At this point, an ng command will be generated. ng common commands:
ng new project name Create a new angular project
ng build -prod production environment compilation
ng serve starts the development server
ng serve --port specifies the port number
of the test
IDE configuration:
VSCode
Debug plugin Angualr2+Snippets plugin
Extensions → Search for Debug to find Debugger for Chrome
Angular2+ Snippets
Install Augury extension for Chrome
Use Augury to query dependency graphs, project structures, and more
in package.json:
Use the npm --save command and the dependencies will be recorded in "dependencies"
Use the npm --save -dev command and the dependencies will be recorded in "devDependencies"
Software runtime dependencies are in dependencies , while development and testing dependencies can be in devDependencies
Error in installing @angular/cli Solution:
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/[email protected]
until there are no errors.