TypeScript definitions for process.env.NODE_ENV?

Update for Node 8:

Now env is declared as ProcessEnv in DefinitelyTyped.

env: ProcessEnv;

export interface ProcessEnv {
    [key: string]: string | undefined;
}

TypeScript 2 supports npm package type definitions for node. It currently uses the DefinitivelyTyped node.d.ts.

npm install --save-dev @types/node

Pre Node 8 version:

process env is declared as any in DefinitelyTyped node.d.ts.

env: any;

The definitions for the 'process' variable can be found in default node.js d.ts from definitely typed and added in your typings.json like this:

"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"

I do not think there are any definitions for the particular NODE_ENV variable. As it is just a convention (widely used by express link) and node.js itself does not care about that specific environment variable.

Tags:

Typescript