meta_desc: Learn to use Node.js languages like JavaScript and TypeScript with Pulumi for infrastructure as code on any cloud (AWS, Azure, Google Cloud, Kubernetes, etc.).
Pulumi supports writing your infrastructure as code in any JavaScript language running on Node.js using any of the [Current, Active and Maintenance LTS versions](https://nodejs.org/en/about/releases/).
The Pulumi programming model includes a core concept of `Input` and `Output` values, which are used to track how outputs of one resource flow in as inputs to another resource. This concept is important to understand when getting started with JavaScript and Pulumi, and the [Inputs and Outputs](/docs/concepts/inputs-outputs/) documentation is recommended to get a feel for how to work with this core part of Pulumi in common cases.
Pulumi executes your program by loading the entrypoint file as a Node module: `require("index.ts")`. By default, Pulumi will load `index.ts` or `index.js`. Alternatively, if you specify `main` within your `package.json`, Pulumi will load that module instead:
```json
{
"name": "my-package",
"version": "1.0.0",
...
"main": "src/entry.ts"
}
```
{{<chooserlanguage"javascript,typescript">}}
Your entrypoint can either return a module object with properties for each stack output:
{{% choosable language "javascript" %}}
```javascript
// create resources
...
exports.out = myResource.output;
```
{{% /choosable %}}
{{% choosable language "typescript" %}}
```typescript
// create resources
...
export const out = myResource.output;
```
{{% /choosable %}}
Or alternatively, your entrypoint can export a top level `async` function that returns an object with members for each stack output.
Pulumi will automatically call this function and await the result:
Most Pulumi programs use the first option, but programs that need to do async work at the top level (such as calling [`getOutputValue`](/docs/reference/pkg/nodejs/pulumi/pulumi#StackReference-getOutputValue)) may find they want to use the second.
You can elect to write Pulumi programs in TypeScript to get additional verification and tooling benefits. Pulumi supports TypeScript natively so you don't need to explicitly run `tsc` on your program before running `pulumi`.
If you would like full control of the TypeScript build process, you can compile ahead of time, and point your package.json main entry point at the compiled JavaScript instead. If you do this, you can disable the [automatic compilation of TypeScript files](#disabling-built-in-typescript-support).
The fastest way to get started with Pulumi in TypeScript, is to use a template:
```bash
$ mkdir myproject && cd myproject
$ pulumi new typescript
```
This will auto-generate all the basic artifacts required to use TypeScript. If you prefer, you can instead run the following manual steps.
### 1. Update package.json
Update your `package.json` to look like the following (with your own values for `name`, `version`, etc.). This
is what tells Node.js and NPM what packages you depend on, where to find your code's entry points, and so on:
You can customize this however you'd like, such as adding test scripts, npm package dependencies, etc. For more information on `package.json`, refer to [the NPM documentation](https://docs.npmjs.com/files/package.json).
Run `npm install` or `yarn install` to install the new development-time dependencies to your `node_modules` directory.
### 3. Create tsconfig.json
When using Pulumi's built in TypeScript support, a `tsconfig.json` file is optional. However, defining one allows your to set additional TypeScript compiler options, for example not allowing implicit returns from a function. In addition, other tools like VS Code will use these settings to give you additional warnings at development time. Any options set in your `tsconfig.json` file will be picked up by Pulumi. We recommend creating a `tsconfig.json` file with the following settings:
You may customize this however you'd like, including the TypeScript settings that work for you. For
information on additional settings, see the [TypeScript documentation for `tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
Tools like VS Code will give you completion lists, live error reporting and inline documentation help.
<imgsrc="/images/docs/reference/vscode.png"alt="Pulumi TypeScript in VS Code"width="700">