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 cta@7.22.0 (nextjs 13) but is throwing an error on cta@7.26.0 (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\monday-sdk-js@0.5.3\node_modules\monday-sdk-js\src\monday-api-client\fetch.js (5:9) @ fetch
⨯ TypeError: fetch is not a function
node_modules\.pnpm\monday-sdk-js@0.5.3\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
I am still struggling with this.
cje
cje3mo ago
Can you check if this also happens with a vanilla create-next-app?
Trader Launchpad
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;