## TL;DR

Issue stripe/stripe-node#2207 (closed, 18 comments): ### Describe the bug When installing either the version 17.0.0 or 17.1.0 in a brand new next.js 14 from scratch after initializing stripe `` import Stripe from 'stripe'; export const stripe = new Stripe(process.env.STRIPE\_SECRET\_KEY as string, { apiVersion: '2024-06-20', typescript: true }) `` I get the following error: Neither apiKey nor config.authenticator provided This issue is not seen after downgrading to 16.12.0

## Steps

1. Issue stripe/stripe-node#2207 (closed, 18 comments): ### Describe the bug

2. When installing either the version 17.0.0 or 17.1.0
in a brand new next.js 14 from scratch after initializing stripe

```
import Stripe from 'stripe';

export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY as string, {
 apiVersion: '2024-06-20',
 typescript: true
})
```

3. I get the following error: Neither apiKey nor config.authenticator provided
This issue is not seen after downgrading to 16.12.0

4. Create a next.js project
adding stripe version 17.1.0
add a lib folder with a new file stripe.ts
with the following:
```
impor

5. [xavdid-stripe (maintainer)]: Confident the issue stems from the env key not being set during build stages in certain environments even though it's available at runtime. v17 added an explicit null-key check in the constructor, so a null `process.env.STRIPE_SECRET_KEY` now raises this error (older versions silently created a broken client). README updated in PR #2238 with suggestions: initialize stripe lazily, put a placeholder key after the env read, or make the API key available earlier in the build.

## When to use

Use this skill when you run into "Neither apiKey nor config.authenticator provided".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: 17.0.0, 17.1.0, 16.12.0. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
