Immutable solution version
Neither apiKey nor config.authenticator provided
Complete solution
Shows how to fix neither apiKey nor config.authenticator provided. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
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
- 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
- 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.
Evidence
Asked in gh:stripe/stripe-node#2207 (https://github.com/stripe/stripe-node/issues/2207): Neither apiKey nor config.authenticator provided. The issue report: 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
To Reproduce
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 The verified answer: [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.By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_AWDmy12Myq4u5w66QD60Mw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Neither apiKey nor config.authenticator provided <span>— Vectle</span></a>