- Check if node is installed using command
- node -v
- If not install using installer available for your operating system
- Install node server using command
Setting up Visual Studio Code
- We will use Visual Studio Code for our development purpose as IDE
- press ctrl+b to hide project view
- To open command prompt
- use ctrl+shift+p
- This will open a small space on top where you can write and execute tasks.
- Write install extension in this area and install angular2 HTML directive snippet extension and other extensions for your angular version.
- You can also add keyboard shortcuts to quickly switch between files and format code.
[
{
"key": "cmd+t",
"command": "workbench.action.quickOpen"
},
{
"key": "shift+cmd+r",
"command": "editor.action.format",
"when": "editorTextFocus"
}
]
To start visual studio code from a folder go to the folder in command prompt and type
To build our project we require following files
- tsconfig.json
- This is the typescript configuration file
- This is the file that tells compiler what to do.
- This file has following contents
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"outDir": "output",
"watch": true
}
}
- tasks.json
- Runs our build
- press ctrl+shift+p and type configure task
- This will generate this file automatically in .vscode folder in the project directory
- launch.json
- used for debugging and running code
- press ctrl+shift+p and type launch json and select Debug:open launch json
- select node as template
- this will create a file launch.json under vscode
- main.ts
- This is our main Typescript file which will be executed.
- Write code in it and run as follows
- Using command in VS Code run Run Build Task
- To terminate send command "terminate running task".
To configure chrome debugger install extension "chrome debugger" in visual studio.
In "launch.json" the "runtimeExecutable" path should correspond to our chrome browser.
Installing Typescript
- Install typescript using command npm i typescript -g
- here npm is the node package manager
- i is for install
- typescript is the name of the software
- g is flag for global install
- Next install typescript definition manager using command
- check the version of both using following commands
- tsd --version
- tsd is typescript definition manager
- tsc --version
- tsc is typescript compiler
No comments:
Post a Comment