Home >Web Front-end >JS Tutorial >About building Angular2 development environment (detailed tutorial)

About building Angular2 development environment (detailed tutorial)

亚连
亚连Original
2018-06-20 16:12:471720browse

Not long ago, WebStorm's frequent freezes finally made me unbearable. I decided to change to a lightweight editor, tried Emacs, Sublime Text, and finally chose vscode. The following article mainly introduces you to the relevant information about VS Code in the Angular2 development environment construction tutorial. Friends in need can refer to it.

Preface

VSCode is a lightweight editor launched by Microsoft. It adopts the same UI interface as VS and is equipped with appropriate plug-ins. Can optimize the front-end development experience.

Layout: The left side is the file manager used to display all the files and folders to be edited, followed by `Explorer`, `Search`, `GIT`, `Debug`, `Plugins` , the right side is the editing area for opening files, and up to three editing areas can be opened to the side at the same time.

Bottom column: `Git Branch`, `error&warning`, `Encoding format`, etc.

1. Set up the development environment Node Js

The Angular2 development environment mainly relies on Node Js and Npm,

requires node 6.9 .x and npm 3.x.x or above.

To view the version command, use node -v and npm -v.

2. For Angular2 or above, use the Angular CLI command line tool

You can quickly create projects, add files, and perform a host of development tasks, such as testing, packaging, and publishing.

Then install Angular CLI globally.

npm install -g @angular/cli

Note: The installation process may be slow and you need to wait for a few minutes.

3. Create a new project

Run the following commands to generate a new project and the skeleton of the application Code:

ng new my-app

Note: The first installation process is also slow, please wait patiently for a few minutes,

4. Start the development server

Enter the project directory and start the server

cd my-app
ng serve --open

ng serveThe command will start Development server that listens for file changes and rebuilds the application when those files are modified.

Use the --open (or -o) parameter to automatically open the browser and access http://localhost:4200/.

5. Open the project in VS Code

##The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to implement floating collision in JS

How to control the mouse to refuse to click the button in JS

How to get the current time difference using JS

How to implement object management of url in js

In JavaScript How to use Generator

The above is the detailed content of About building Angular2 development environment (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn