Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-fetch makes vercel build fail #115

Open
ff6347 opened this issue Jan 2, 2023 · 0 comments
Open

node-fetch makes vercel build fail #115

ff6347 opened this issue Jan 2, 2023 · 0 comments
Assignees

Comments

@ff6347
Copy link
Contributor

ff6347 commented Jan 2, 2023

I had several issues in other repos using node-fetch since the v3.x is ESM only which goes not well with repos using typescript. As an alternative to node-fetch i suggest cross-fetch

[04:29:09.369] Cloning github.com/technologiestiftung/wegweiser-frontend (Branch: renovate/major-devdependencies-major, Commit: 45513f8)
[04:29:09.925] Cloning completed: 555.572ms
[04:29:12.491] Restored build cache
[04:29:12.529] Running "vercel build"
[04:29:13.017] Vercel CLI 28.10.0
[04:29:13.362] Detected `package-lock.json` generated by npm 7+...
[04:29:13.374] Installing dependencies...
[04:29:24.165] 
[04:29:24.165] added 34 packages, removed 115 packages, and changed 92 packages in 10s
[04:29:24.165] 
[04:29:24.165] 167 packages are looking for funding
[04:29:24.165]   run `npm fund` for details
[04:29:24.186] Detected Next.js version: 12.3.4
[04:29:24.195] Running "npm run build"
[04:29:24.491] 
[04:29:24.491] > [email protected] build
[04:29:24.491] > npm run downloadCacheData && IS_BUILDING=true next build
[04:29:24.491] 
[04:29:24.786] 
[04:29:24.786] > [email protected] downloadCacheData
[04:29:24.786] > npx ts-node src/scripts/downloadCacheData.ts
[04:29:24.786] 
[04:29:27.579] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /vercel/path0/node_modules/node-fetch/src/index.js
[04:29:27.580] require() of ES modules is not supported.
[04:29:27.580] require() of /vercel/path0/node_modules/node-fetch/src/index.js from /vercel/path0/src/lib/requests/getGristTableData.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
[04:29:27.580] Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /vercel/path0/node_modules/node-fetch/package.json.
[04:29:27.580] 
[04:29:27.580]     at new NodeError (internal/errors.js:322:7)
[04:29:27.580]     at Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
[04:29:27.580]     at Object.require.extensions.<computed> [as .js] (/vercel/path0/node_modules/ts-node/src/index.ts:1608:43)
[04:29:27.580]     at Module.load (internal/modules/cjs/loader.js:950:32)
[04:29:27.580]     at Function.Module._load (internal/modules/cjs/loader.js:790:12)
[04:29:27.581]     at Module.require (internal/modules/cjs/loader.js:974:19)
[04:29:27.581]     at require (internal/modules/cjs/helpers.js:101:18)
[04:29:27.581]     at Object.<anonymous> (/vercel/path0/src/lib/requests/getGristTableData.ts:1:1)
[04:29:27.581]     at Module._compile (internal/modules/cjs/loader.js:1085:14)
[04:29:27.581]     at Module.m._compile (/vercel/path0/node_modules/ts-node/src/index.ts:1618:23) {
[04:29:27.581]   code: 'ERR_REQUIRE_ESM'
[04:29:27.581] }
[04:29:27.621] Error: Command "npm run build" exited with 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants