Creating a Node.js function using TypeScript
Written by
Updated at July 15, 2025
By default, Node.js does not support TypeScript
-
Install Node.js
. -
Open your project directory.
-
Install TypeScript
:npm install typescript --save-dev -
Create a TypeScript configuration:
npx --no-install tsc --init --preserveConstEnums --moduleResolution Node --isolatedModules --outDir build --strict false --target ES2021To use a different version of JavaScript, change the value of the
targetargument. The latest JavaScript version that can be specified depends on the Node.js version you are using:Node.js version Highest JavaScript version 12 ES2019 14 ES2020 16 ES2021 -
Compile a function:
npx tsc -
The
builddirectory will appear in the project folder. Add its contents to a ZIP archive.