CTA v7.26.0 is giving "fetch is not a function" error

I have a boilerplate create t3 app@latest and installed 1 package the monday-sdk-js package. It works fine with [email protected] (nextjs 13) but is throwing an error on [email protected] (next14). Next13 has to have the experimental server action flag and next14 does not. Same code on both boilerplates but on next14 I am now getting error:
node_modules\.pnpm\[email protected]\node_modules\monday-sdk-js\src\monday-api-client\fetch.js (5:9) @ fetch
⨯ TypeError: fetch is not a function
node_modules\.pnpm\[email protected]\node_modules\monday-sdk-js\src\monday-api-client\fetch.js (5:9) @ fetch
⨯ TypeError: fetch is not a function
Any idea why this is happening?
Solution:
@cje Found the answer. I had to modify next.config: ```...
Jump to solution
4 Replies
Trader Launchpad
Trader LaunchpadOP9mo ago
I am still struggling with this.
cje
cje9mo ago
Can you check if this also happens with a vanilla create-next-app?
Trader Launchpad
Trader LaunchpadOP9mo ago
it does. Also spinning up a ct3app and downgrading the next version to 13.4 fixes the issue. It is something to do with next between 13.4 and 14.x. I believe has something to do with no longer needing the serverAction experimental flag, or the fact that nextjs14 no longer polyfills node-fetch. i have searched for a few days, on nextjs and monday-sdk-js githubs, opened a few issues and discussions. No one has responded.
Solution
Trader Launchpad
@cje Found the answer. I had to modify next.config:
await import("./src/env.mjs");

/** @type {import("next").NextConfig} */
const config = {
experimental: {
serverComponentsExternalPackages: ["monday-sdk-js"],
},
};

export default config;
await import("./src/env.mjs");

/** @type {import("next").NextConfig} */
const config = {
experimental: {
serverComponentsExternalPackages: ["monday-sdk-js"],
},
};

export default config;
Want results from more Discord servers?
Add your server