Deploying a new nuxt 3 app result to error

Hello,

I’ve created a new nuxt 3 app and tried to delopy it to netlify with github:
stoic-fermat-995d10

The build stop when It comes to .netlify/functions-internal/

A Netlify Function failed to require one of its dependencies.
Please make sure it is present in the site's top-level "package.json".​

Exemple:
.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)

Here is the log below:


3:02:51 PM: Build ready to start
3:02:53 PM: build-image version: c5b01a919d3e16af69445c5de0cacb49efbb1a23 (focal)
3:02:53 PM: build-image tag: v4.4.0
3:02:53 PM: buildbot version: 8511f0f084c05704fd035b9cf5b612081353f86f
3:02:53 PM: Fetching cached dependencies
3:02:53 PM: Failed to fetch cache, continuing with build
3:02:53 PM: Starting to prepare the repo for build
3:02:53 PM: No cached dependencies found. Cloning fresh repo
3:02:53 PM: git clone https://github.com/arnauddsj/indiefamily
3:02:54 PM: Preparing Git Reference refs/heads/main
3:02:55 PM: Parsing package.json dependencies
3:02:55 PM: Starting build script
3:02:56 PM: Installing dependencies
3:02:56 PM: Python version set to 2.7
3:02:56 PM: Downloading and installing node v16.13.0...
3:02:57 PM: Downloading https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.xz...
3:02:57 PM: Computing checksum with sha256sum
3:02:57 PM: Checksums matched!
3:03:00 PM: Now using node v16.13.0 (npm v8.1.0)
3:03:01 PM: Started restoring cached build plugins
3:03:01 PM: Finished restoring cached build plugins
3:03:01 PM: Attempting ruby version 2.7.2, read from environment
3:03:02 PM: Using ruby version 2.7.2
3:03:02 PM: Using PHP version 8.0
3:03:02 PM: Started restoring cached node modules
3:03:02 PM: Finished restoring cached node modules
3:03:03 PM: Installing NPM modules using NPM version 8.1.0
3:03:11 PM: npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
3:03:13 PM: npm WARN deprecated node-pre-gyp@0.13.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
3:03:18 PM: added 792 packages, and audited 793 packages in 14s
3:03:18 PM: 112 packages are looking for funding
3:03:18 PM:   run `npm fund` for details
3:03:18 PM: 3 moderate severity vulnerabilities
3:03:18 PM: To address all issues, run:
3:03:18 PM:   npm audit fix
3:03:18 PM: Run `npm audit` for details.
3:03:18 PM: NPM modules installed
3:03:18 PM: Started restoring cached go cache
3:03:18 PM: Finished restoring cached go cache
3:03:18 PM: go version go1.16.5 linux/amd64
3:03:18 PM: go version go1.16.5 linux/amd64
3:03:18 PM: Installing missing commands
3:03:18 PM: Verify run directory
3:03:20 PM: ​
3:03:20 PM: ────────────────────────────────────────────────────────────────
3:03:20 PM:   Netlify Build                                                 
3:03:20 PM: ────────────────────────────────────────────────────────────────
3:03:20 PM: ​
3:03:20 PM: ❯ Version
3:03:20 PM:   @netlify/build 18.21.8
3:03:20 PM: ​
3:03:20 PM: ❯ Flags
3:03:20 PM:   baseRelDir: true
3:03:20 PM:   buildId: 618a7f8bf40f2e52978375ba
3:03:20 PM:   deployId: 618a7f8bf40f2e52978375bc
3:03:20 PM: ​
3:03:20 PM: ❯ Current directory
3:03:20 PM:   /opt/build/repo
3:03:20 PM: ​
3:03:20 PM: ❯ Config file
3:03:20 PM:   No config file was defined: using default values.
3:03:20 PM: ​
3:03:20 PM: ❯ Context
3:03:20 PM:   production
3:03:20 PM: ​
3:03:20 PM: ────────────────────────────────────────────────────────────────
3:03:20 PM:   1. Build command from Netlify app                             
3:03:20 PM: ────────────────────────────────────────────────────────────────
3:03:20 PM: ​
3:03:20 PM: $ npm run build
3:03:20 PM: > build
3:03:20 PM: > nuxi build
3:03:20 PM: [log] Nuxt CLI v3.0.0-27274229.29599f0
3:03:25 PM: [info] Vite warmed up in 1490ms
3:03:25 PM: [info] Client built in 2110ms
3:03:25 PM: [info] Building server...
3:03:26 PM: [success] Server built in 886ms
3:03:26 PM: [info] Nitro preset is netlify
3:03:26 PM: [info] Cleaning up .netlify/functions-internal
3:03:26 PM: [info] Cleaning up dist
3:03:26 PM: [start] Generating public...
3:03:26 PM: [success] Generated public dist
3:03:26 PM: [start] Building server...
3:03:30 PM: [start] Writing server bundle...
3:03:30 PM: [success] Server built
3:03:31 PM:   ├─ .netlify/functions-internal/server/server.ts (69.4 kB) (25.5 kB gzip)
3:03:31 PM:   ├─ .netlify/functions-internal/server/chunks/index.mjs (390 kB) (89.9 kB gzip)
3:03:31 PM:   ├─ .netlify/functions-internal/server/chunks/app/vue3.mjs (284 B) (200 B gzip)
3:03:31 PM:   ├─ .netlify/functions-internal/server/chunks/app/server.mjs (144 kB) (35.7 kB gzip)
3:03:31 PM:   ├─ .netlify/functions-internal/server/chunks/app/render.mjs (22.5 kB) (6.24 kB gzip)
3:03:31 PM:   └─ .netlify/functions-internal/server/chunks/app/client.manifest.mjs (278 B) (182 B gzip)
3:03:31 PM: Σ Total size: 957 kB (236 kB gzip)
3:03:32 PM: ​
3:03:32 PM: (build.command completed in 11.9s)
3:03:32 PM: ​
3:03:32 PM: ────────────────────────────────────────────────────────────────
3:03:32 PM:   2. Functions bundling                                         
3:03:32 PM: ────────────────────────────────────────────────────────────────
3:03:32 PM: ​
3:03:32 PM: Packaging Functions from .netlify/functions-internal directory:
3:03:32 PM:  - server/server.ts
3:03:32 PM: ​
3:03:32 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)
3:03:32 PM:     9 │ import http from 'node:http';
3:03:32 PM:       ╵                  ~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     10 │ import https from 'node:https';
3:03:32 PM:        ╵                   ~~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     11 │ import zlib from 'node:zlib';
3:03:32 PM:        ╵                  ~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     12 │ import Stream, {PassThrough, pipeline as pump} from 'node:stream';
3:03:32 PM:        ╵                                                     ~~~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     8 │ import Stream, {PassThrough} from 'node:stream';
3:03:32 PM:       ╵                                   ~~~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     7 │ import {types} from 'node:util';
3:03:32 PM:       ╵                     ~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     9 │ import {types, deprecate} from 'node:util';
3:03:32 PM:       ╵                                ~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     8 │ import http from 'node:http';
3:03:32 PM:       ╵                  ~~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     10 │ import {format as formatUrl} from 'node:url';
3:03:32 PM:        ╵                                   ~~~~~~~~~~
3:03:32 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)
3:03:32 PM:     1 │ import { statSync, createReadStream, promises as fs } from 'node:fs'
3:03:32 PM:       ╵                                                            ~~~~~~~~~
3:03:32 PM: 10 of 12 errors shown (disable the message limit with --log-limit=0)
3:03:32 PM: ​
3:03:32 PM: ────────────────────────────────────────────────────────────────
3:03:32 PM:   Dependencies installation error                               
3:03:32 PM: ────────────────────────────────────────────────────────────────
3:03:32 PM: ​
3:03:32 PM:   Error message
3:03:32 PM:   A Netlify Function failed to require one of its dependencies.
3:03:32 PM:   Please make sure it is present in the site's top-level "package.json".​
3:03:32 PM:   Build failed with 12 errors:
3:03:32 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)
3:03:32 PM:   .netlify/functions-internal/server/node_modules/fetch-blob/from.js:2:25: error: Could not resolve "node:path" (mark it as external to exclude it from the bundle)
3:03:32 PM:   .netlify/functions-internal/server/node_modules/fetch-blob/from.js:3:31: error: Could not resolve "node:worker_threads" (mark it as external to exclude it from the bundle)
3:03:32 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)
3:03:32 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)
3:03:32 PM:   ...
3:03:32 PM: ​
3:03:32 PM:   Resolved config
3:03:32 PM:   build:
3:03:32 PM:     command: npm run build
3:03:32 PM:     commandOrigin: ui
3:03:32 PM:     environment:
3:03:32 PM:       - NOD_ENV
3:03:32 PM:     publish: /opt/build/repo/dist
3:03:32 PM:     publishOrigin: ui
3:03:32 PM:   redirects:
3:03:32 PM:     - from: /*      status: 200      to: /.netlify/functions/serverCaching artifacts
3:03:32 PM: Started saving node modules
3:03:32 PM: Finished saving node modules
3:03:32 PM: Started saving build plugins
3:03:32 PM: Finished saving build plugins
3:03:32 PM: Started saving pip cache
3:03:32 PM: Finished saving pip cache
3:03:32 PM: Started saving emacs cask dependencies
3:03:32 PM: Finished saving emacs cask dependencies
3:03:32 PM: Started saving maven dependencies
3:03:32 PM: Finished saving maven dependencies
3:03:32 PM: Started saving boot dependencies
3:03:32 PM: Finished saving boot dependencies
3:03:32 PM: Started saving rust rustup cache
3:03:32 PM: Finished saving rust rustup cache
3:03:32 PM: Started saving go dependencies
3:03:32 PM: Finished saving go dependencies
3:03:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:03:35 PM: Creating deploy upload records
3:03:35 PM: Failing build: Failed to build site
3:03:35 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
3:03:35 PM: Finished processing build request in 42.217270422s

I don’t understand why I get error as on nuxt doc they say to just push like any other push on netlify.
Any thing I’m doing wrong ?

Thank you !

Hi @arnauddsj,

Not sure if this is you, but looks like there’s a related open issue here:

Our team is investigating it. We’ll post an update as we have it.

1 Like

This should be fixed at the moment. Could you retry?

Hi @hrishikesh,

I have the same Problem, the build works now, but when i try to access the site i get the following response:

{
  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module 'node:http'\nRequire stack:\n- /var/task/.netlify/functions-internal/server/server.js\n- /var/task/server.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "trace": [
    "Runtime.ImportModuleError: Error: Cannot find module 'node:http'",
    "Require stack:",
    "- /var/task/.netlify/functions-internal/server/server.js",
    "- /var/task/server.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
    "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
    "    at Module.load (internal/modules/cjs/loader.js:863:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
    "    at internal/main/run_main_module.js:17:47"
  ]
}

Hello thank you for the link to the issue.
There is still an error, but the issue is live.

Thank you for letting us know. The team is continuing the investigation.

Hi @hrishikesh , I’m trying to deploy Remix app right now and I’m getting the same error log as original question here.

Since node 18 is not yet an option I’m wondering what the status on this issue is. I’m not sure it was fixed in the meantime or still not?

Hey @pawelphilipczyk

Could you share your site URL to check? This post is almost a year old so this should not be happening anymore, or at least should not be the exact error.

Yes, that’s why I’m surprised that I see it :slight_smile:
https://empik-bestsellers.netlify.app

You’re having issues during site build and not during bundling functions - for site builds, I believe you can use Node 18:

Thank you for such quick responses. I did try with NODE_VERSION=18 too but that gives the same error and I still cannot get rid of node-fetch anyway as it’s needed in AWS where node version will be 16 anyway right?

Yeah, that seems like a valid assertion. Let me investigate further…

1 Like

I can’t seem to find the cause for this, is it possible for you to share a minimal reproduction?

Here’s a branch I’m deploying from.

Let me know if this is not enough: GitHub - pawelphilipczyk/empik-bestsellers at netlify

Hey @pawelphilipczyk,

Sorry for the delay. It appears, it could be because of:

Since you’re trying to use the netlify-edge preset, maybe that’s causing issues. Are you able to deploy it with non-edge preset?

Hi, do you have any result about it. I have the same problem and I am not using netlify-edge present.

What site are you asking about @super12431?