Home
Support Forums

Error: ENOENT - I'm getting this error while trying to build my site on Netlify

Hi, I am having a problem when trying to deploy my site.
Site name: happy-mcnulty-e8f9df
Github: GitHub - Caweca105/portfolio

And the log that appears to me is the following:

9:48:20 PM: Build ready to start
9:48:22 PM: build-image version: c5b01a919d3e16af69445c5de0cacb49efbb1a23 (focal)
9:48:22 PM: build-image tag: v4.4.0
9:48:22 PM: buildbot version: 8511f0f084c05704fd035b9cf5b612081353f86f
9:48:22 PM: Building without cache
9:48:22 PM: Starting to prepare the repo for build
9:48:22 PM: No cached dependencies found. Cloning fresh repo
9:48:22 PM: git clone GitHub - Caweca105/portfolio
9:48:24 PM: Preparing Git Reference refs/heads/Main
9:48:24 PM: Parsing package.json dependencies
9:48:25 PM: Starting build script
9:48:25 PM: Installing dependencies
9:48:25 PM: Python version set to 2.7
9:48:26 PM: Downloading and installing node v16.13.0…
9:48:26 PM: Downloading https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.xz…
9:48:27 PM: Computing checksum with sha256sum
9:48:27 PM: Checksums matched!
9:48:30 PM: Now using node v16.13.0 (npm v8.1.0)
9:48:30 PM: Started restoring cached build plugins
9:48:30 PM: Finished restoring cached build plugins
9:48:31 PM: Attempting ruby version 2.7.2, read from environment
9:48:32 PM: Using ruby version 2.7.2
9:48:33 PM: Using PHP version 8.0
9:48:33 PM: Started restoring cached node modules
9:48:33 PM: Finished restoring cached node modules
9:48:33 PM: Installing NPM modules using NPM version 8.1.0
9:48:42 PM: npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:48:48 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:48:56 PM: added 625 packages, and audited 626 packages in 22s
9:48:56 PM: 88 packages are looking for funding
9:48:56 PM: run npm fund for details
9:48:56 PM: found 0 vulnerabilities
9:48:56 PM: NPM modules installed
9:48:56 PM: Started restoring cached go cache
9:48:56 PM: Finished restoring cached go cache
9:48:56 PM: go version go1.16.5 linux/amd64
9:48:56 PM: go version go1.16.5 linux/amd64
9:48:56 PM: Installing missing commands
9:48:56 PM: Verify run directory
9:48:58 PM: ​
9:48:58 PM: ────────────────────────────────────────────────────────────────
9:48:58 PM: Netlify Build
9:48:58 PM: ────────────────────────────────────────────────────────────────
9:48:58 PM: ​
9:48:58 PM: ❯ Version
9:48:58 PM: @netlify/build 18.21.8
9:48:58 PM: ​
9:48:58 PM: ❯ Flags
9:48:58 PM: baseRelDir: true
9:48:58 PM: buildId: 61899b24a1a41c62abc714f2
9:48:58 PM: deployId: 61899b24a1a41c62abc714f4
9:48:58 PM: ​
9:48:58 PM: ❯ Current directory
9:48:58 PM: /opt/build/repo
9:48:58 PM: ​
9:48:58 PM: ❯ Config file
9:48:58 PM: No config file was defined: using default values.
9:48:58 PM: ​
9:48:58 PM: ❯ Context
9:48:58 PM: production
9:48:58 PM: ​
9:48:58 PM: ❯ Installing plugins
9:48:58 PM: - @netlify/plugin-nextjs@3.9.2
9:49:10 PM: ​
9:49:10 PM: ❯ Loading plugins
9:49:10 PM: - @netlify/plugin-nextjs@3.9.2 from Netlify app
9:49:11 PM: ​
9:49:11 PM: ────────────────────────────────────────────────────────────────
9:49:11 PM: 1. @netlify/plugin-nextjs (onPreBuild event)
9:49:11 PM: ────────────────────────────────────────────────────────────────
9:49:11 PM: ​
9:49:11 PM: Using Next.js 11.1.2
9:49:11 PM: Warning: support for Next.js >=11.1.0 is experimental
9:49:11 PM: info - Using webpack 5. Reason: Enabled by default webpack5 | Next.js
9:49:11 PM: The β€œtarget” config property must be one of β€œserverless”, β€œexperimental-serverless-trace”. Building with β€œserverless” target.
9:49:12 PM: info - Using webpack 5. Reason: Enabled by default webpack5 | Next.js
9:49:12 PM: No Next.js cache to restore.
9:49:12 PM: ​
9:49:12 PM: (@netlify/plugin-nextjs onPreBuild completed in 1s)
9:49:12 PM: ​
9:49:12 PM: ────────────────────────────────────────────────────────────────
9:49:12 PM: 2. Build command from Netlify app
9:49:12 PM: ────────────────────────────────────────────────────────────────
9:49:12 PM: ​
9:49:12 PM: $ npm run dev
9:49:12 PM: > homepage@1.0.0 dev
9:49:12 PM: > next dev -H 0.0.0.0
9:49:13 PM: ready - started server on 0.0.0.0:3000, url: ########
9:49:13 PM: info - Using webpack 5. Reason: Enabled by default //https://nextjs.org/docs/messages/webpack5
9:49:30 PM: event - compiled successfully
10:18:20 PM: Build exceeded maximum allowed runtime
10:18:20 PM: wait - compiling…
10:18:20 PM: error - ./node_modules/ansi-regex/index.js
10:18:20 PM: Error: ENOENT: no such file or directory, open β€˜/opt/build/repo/node_modules/ansi-regex/index.js’
10:18:20 PM: wait - compiling…
10:18:22 PM: > Found a change in next.config.js. Restart the server to see the changes in effect.
10:18:24 PM: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: ENOENT: no such file or directory, open β€˜/opt/build/repo/.next/cache/webpack/client-development/0.pack_’
10:18:24 PM: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: ENOENT: no such file or directory, rename β€˜/opt/build/repo/.next/cache/webpack/server-development/1.pack_’ β†’ β€˜/opt/build/repo/.next/cache/webpack/server-development/1.pack’

Thanks in advance

Hi @Caweca105

npm run dev won’t work on Netlify as you cannot run a dev server. Can you change the build command to npm run build and see if you still get the same error.

2 Likes

And you were totally correct. Thank you so much for your help.

1 Like