nuxt: Netlify Build Failing
Environment
- Operating System:
Darwin - Node Version:
v14.18.1 - Nuxt Version:
0.0.0 - Package Manager:
yarn@1.22.10 - Bundler:
Webpack - User Config:
- - Runtime Modules:
- - Build Modules:
-
Describe the bug
Am I doing something wrong?
Netlify Deploy is failing
1:48:13 PM: 2. Functions bundling
1:48:13 PM: ────────────────────────────────────────────────────────────────
1:48:13 PM:
1:48:13 PM: Packaging Functions from .netlify/functions-internal directory:
1:48:13 PM: - server/server.ts
1:48:13 PM:
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/index.js:9:17: error: Could not resolve "node:http" (mark it as external to exclude it from the bundle)
1:48:13 PM: 9 │ import http from 'node:http';
1:48:13 PM: ╵ ~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/index.js:10:18: error: Could not resolve "node:https" (mark it as external to exclude it from the bundle)
1:48:13 PM: 10 │ import https from 'node:https';
1:48:13 PM: ╵ ~~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/index.js:11:17: error: Could not resolve "node:zlib" (mark it as external to exclude it from the bundle)
1:48:13 PM: 11 │ import zlib from 'node:zlib';
1:48:13 PM: ╵ ~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/index.js:12:52: error: Could not resolve "node:stream" (mark it as external to exclude it from the bundle)
1:48:13 PM: 12 │ import Stream, {PassThrough, pipeline as pump} from 'node:stream';
1:48:13 PM: ╵ ~~~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/body.js:8:34: error: Could not resolve "node:stream" (mark it as external to exclude it from the bundle)
1:48:13 PM: 8 │ import Stream, {PassThrough} from 'node:stream';
1:48:13 PM: ╵ ~~~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/body.js:9:31: error: Could not resolve "node:util" (mark it as external to exclude it from the bundle)
1:48:13 PM: 9 │ import {types, deprecate} from 'node:util';
1:48:13 PM: ╵ ~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/request.js:10:34: error: Could not resolve "node:url" (mark it as external to exclude it from the bundle)
1:48:13 PM: 10 │ import {format as formatUrl} from 'node:url';
1:48:13 PM: ╵ ~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/headers.js:7:20: error: Could not resolve "node:util" (mark it as external to exclude it from the bundle)
1:48:13 PM: 7 │ import {types} from 'node:util';
1:48:13 PM: ╵ ~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/node-fetch/src/headers.js:8:17: error: Could not resolve "node:http" (mark it as external to exclude it from the bundle)
1:48:13 PM: 8 │ import http from 'node:http';
1:48:13 PM: ╵ ~~~~~~~~~~~
1:48:13 PM: > .netlify/functions-internal/server/node_modules/fetch-blob/from.js:1:59: error: Could not resolve "node:fs" (mark it as external to exclude it from the bundle)
1:48:13 PM: 1 │ import { statSync, createReadStream, promises as fs } from 'node:fs'
1:48:13 PM: ╵ ~~~~~~~~~
1:48:13 PM: 10 of 12 errors shown (disable the message limit with --log-limit=0)
1:48:13 PM:
1:48:13 PM: ────────────────────────────────────────────────────────────────
1:48:13 PM: Dependencies installation error
1:48:13 PM: ────────────────────────────────────────────────────────────────
1:48:13 PM:
Reproduction
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 36 (23 by maintainers)
I deployed https://github.com/netlify/zip-it-and-ship-it/pull/806 to production. The issue should not occur anymore. If it does, please let me know 😃
fixed thank you
This seems like a regression related to a change I introduced into Netlify’s bundling process. Looking into it!
Separately, @danielroe: I’ve confirmed that this should work for us too, and would mean it woudln’t be re-bundled.
It’s node-fetch that’s the problem: they claim to support Node 12, but in the latest release changed all the imports to use the prefix. I’m going to open an issue.
Yes! Most importantly for dealing with
esm-onlypackages. If we output CJS format should bundle all or some of the externals as well losing benefit of vercel/nft.@pi0 That does sound like the simplest solution. Changing it to .js should just work: it will switch back to the default bundler, which doesn’t compile anything. I made the entrypoint
.tsbecause at the time that was the simplest way to switch the bundler intoesbuildmode without needing to add any config (now.mjswill do the same).Environment
Darwinv16.13.03.0.0-27277330.202617byarn@1.22.15VitebuildModules,build-@pinia/nuxt@0.1.5Describe the bug
https://v3nuxt.netlify.app
Reproduction
https://github.com/productdevbook/nuxt3-app
Additional context
No response
Logs
No response
Fixed !
Updated env vars only go into effect on new deploys, did you redeploy your site?
It still doesn’t work. I just deployed it, here is the link https://youthful-gates-3fd198.netlify.app/.
I think it just might be possible to emit the right kind of entrypoint (while keeping the rest of the lambda ESM). There are some examples out there of people who’ve done the same with AWS Lambda, e.g. here.
Correct. AWS lambda doesn’t support ESM, so we need to transpile it all. If Nitro can generate a node 14 -compatible cjs bundle then it could run it unchanged
I was able to reproduce & fix this in https://github.com/netlify/zip-it-and-ship-it/pull/802 🥳 Will ping here once it’s deployed.
There’s a related thread on Netlify Forums: https://answers.netlify.com/t/deploying-a-new-nuxt-3-app-result-to-error/47029
Hey. This certainly seems to be a bundling issue. The
node:-prefix import issue came up before, but I thought we had fixed it. Tagging @eduardoboucas to see if he has any insightThen I think this should be raised upstream with Netlify as it’s happening not within the Nuxt build step but within packaging functions.
cc: @ascorbic