# Migration (v5 to v6)

Upgrade to envapt v6, which removes positional decorators and reads NODE_ENV=test as test.

v6 removes the positional decorator form and changes what `NODE_ENV=test` resolves to.

> **TIP**
>
> Upgrading further? v7 makes the decorators TC39 accessor decorators by default. See [Migration (v6 to
> v7)](/docs/migration-v6-to-v7).

## Decorators

The positional `@Envapt('KEY', fallback, converter)` form, deprecated in v5, is removed. Use the options object, or a [sugar decorator](/docs/decorators) for the common case. The no-argument `@Envapt('KEY')` form is unchanged.

```ts
// v5 (removed in v6)
@Envapt('PORT', 8080, Number)

// v6 options object
@Envapt('PORT', { converter: Converters.Number, fallback: 8080 })

// v6 sugar decorator, shorter than the old positional form
@EnvNum('PORT', 8080)
```

The sugar decorators `@EnvNum`, `@EnvStr`, `@EnvBool`, `@EnvUrl`, and `@EnvTime` each wrap a built-in converter, so you pass only the key and the fallback. If the second argument isn't an options object, the decorator now throws `EnvaptError` with `InvalidUserDefinedConfig` when the class is defined, so a leftover positional call stops the app at startup. The internal `InferPrimitiveFallbackType` type is removed with the overload.

## Behavior changes to watch

> **DANGER**
>
> This change compiles without edits but runs differently from v5. Check it before upgrading.

- **`NODE_ENV=test` resolves to `Environment.Test`.** Jest and vitest set `NODE_ENV=test`, so under either one `Envapter.isTest` returns true and `isDevelopment` returns false. v5.1 and earlier returned true from `isDevelopment` there. Vite's `MODE=test` also resolves to `Environment.Test`. This first shipped by mistake in the 5.2.0 minor, which is deprecated on npm. If you branch on `isDevelopment` inside tests, switch to `isTest` or set `Envapter.environment` yourself, as [Environment](/docs/environment) shows.