Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to develop applications with typescript and nodejs

Shulou Source: shulou.com Published: 2022-06-02 10:00:39 10月06日 Update

This article focuses on "how to use typescript and nodejs to develop applications", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to develop applications with typescript and nodejs.

Environment building

First we need to install ts-node and typescript

Npm install-g ts-nodenpm install-g typescript

After the global installation is complete, you can test whether the installation is successful.

$ts-node-vv8.3.0$ tsc-vVersion 3.5.2

Let's print the version information separately.

Build application

Let's create a main.ts file that can be simpler.

Let str:string = "this is what is used for testing" console.log (str)

See if you can run the main.ts file directly

Ts-node main.ts

We can also add this command to the package.json file

"scripts": {"test": "echo\" Error: no test specified\ "& & exit 1", "start": "ts-node src/main.ts"}

This is what we just need to run

Npm run start

The result is the same as using the ts-node command directly.

Using typescript to develop nodejs applications allows us to manage our own applications well, and long-term use will also make us form a good habit.

At this point, I believe you have a deeper understanding of "how to develop applications with typescript and nodejs". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Application development content file command this is learning testing running practical deeper successful information global interest practical practical easy to operate method more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Redmi macOS Xiaomi