Hi,
I’m trying to migrate my personal website over from standard Next to Remix. The build completes locally without errors. However, when Netlify tries to build, it fails with the following message:
Error: The directory "/opt/build/repo/public" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
(As a side note: it’d be really helpful if this log contained more information about what’s happening in the container! Since the build succeeds locally, and I wasn’t able to find help in the docs or elsewhere about this, there are no leads here for me to start debugging with.)
I’m using the same build command and directory that were recommended in the Netlify docs for Remix (remix build
and public
).
Site name: charlenechambliss.com
I also tried creating a new site specifically for this branch at https://63cdd5faf84df0341583ba9c--gregarious-tapioca-ddafaa.netlify.app/ . Oddly enough, this build succeeds, but then I get Page Not Found when navigating to the URL (including if I try adding index.html
).
Build log below. Let me know if there’s anything else I can try/add that would be helpful.
Thank you!
4:43:13 PM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
4:43:13 PM: build-image tag: v4.16.3
4:43:13 PM: buildbot version: 211709fe0bb687fe4fe2ebbb0a0d7258aa6e265c
4:43:13 PM: Fetching cached dependencies
4:43:13 PM: Failed to fetch cache, continuing with build
4:43:13 PM: Starting to prepare the repo for build
4:43:14 PM: No cached dependencies found. Cloning fresh repo
4:43:14 PM: git clone --filter=blob:none --no-checkout https://github.com/chambliss/new-site
4:43:14 PM: Preparing Git Reference refs/heads/main
4:43:15 PM: Parsing package.json dependencies
4:43:16 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'netlify/functions' versus '' in the Netlify UI
4:43:16 PM: Starting build script
4:43:16 PM: Installing dependencies
4:43:16 PM: Python version set to 2.7
4:43:16 PM: Attempting Node.js version 'v18.5.0' from .nvmrc
4:43:17 PM: Downloading and installing node v18.5.0...
4:43:17 PM: Downloading https://nodejs.org/dist/v18.5.0/node-v18.5.0-linux-x64.tar.xz...
4:43:17 PM: Computing checksum with sha256sum
4:43:17 PM: Checksums matched!
4:43:19 PM: Now using node v18.5.0 (npm v8.12.1)
4:43:19 PM: Enabling Node.js Corepack
4:43:19 PM: Started restoring cached build plugins
4:43:19 PM: Finished restoring cached build plugins
4:43:19 PM: Attempting Ruby version 2.7.2, read from environment
4:43:20 PM: Using Ruby version 2.7.2
4:43:20 PM: Using PHP version 8.0
4:43:20 PM: Started restoring cached corepack dependencies
4:43:20 PM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
4:43:20 PM: Finished restoring cached corepack dependencies
4:43:20 PM: No npm workspaces detected
4:43:20 PM: Started restoring cached node modules
4:43:20 PM: Finished restoring cached node modules
4:43:20 PM: Bypassing sha validation. Running pre & post install scripts
4:43:20 PM: Installing npm packages using npm version 8.12.1
4:43:24 PM: npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
4:43:24 PM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
4:43:25 PM: npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
4:43:28 PM: npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
4:43:30 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
4:43:30 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
4:43:45 PM: added 1489 packages, and audited 1490 packages in 24s
4:43:45 PM: 263 packages are looking for funding
4:43:45 PM: run `npm fund` for details
4:43:45 PM: 2 vulnerabilities (1 low, 1 high)
4:43:45 PM: To address all issues, run:
4:43:45 PM: npm audit fix
4:43:45 PM: Run `npm audit` for details.
4:43:45 PM: npm packages installed
4:43:45 PM: Started restoring cached go cache
4:43:45 PM: Finished restoring cached go cache
4:43:45 PM: Installing Go version 1.17 (requested 1.17)
4:43:49 PM: unset GOOS;
4:43:49 PM: unset GOARCH;
4:43:49 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
4:43:49 PM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
4:43:49 PM: go version >&2;
4:43:49 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
4:43:49 PM: go version go1.17 linux/amd64
4:43:50 PM: Detected 1 framework(s)
4:43:50 PM: "vite" at version "3.2.3"
4:43:50 PM: Installing missing commands
4:43:50 PM: Verify run directory
4:43:50 PM: Section completed: initializing
4:43:51 PM:
4:43:51 PM: Netlify Build
4:43:51 PM: ────────────────────────────────────────────────────────────────
4:43:51 PM:
4:43:51 PM: ❯ Version
4:43:51 PM: @netlify/build 29.5.1
4:43:51 PM:
4:43:51 PM: ❯ Flags
4:43:51 PM: baseRelDir: true
4:43:51 PM: buildId: 63cdd820d95001000873979f
4:43:51 PM: deployId: 63cdd820d9500100087397a1
4:43:51 PM:
4:43:51 PM: ❯ Current directory
4:43:51 PM: /opt/build/repo
4:43:51 PM:
4:43:51 PM: ❯ Config file
4:43:51 PM: /opt/build/repo/netlify.toml
4:43:51 PM:
4:43:51 PM: ❯ Context
4:43:51 PM: production
4:43:51 PM:
4:43:51 PM: ❯ Using Next.js Runtime - v4.30.0
4:43:53 PM:
4:43:53 PM: 1. @netlify/plugin-nextjs (onPreBuild event)
4:43:53 PM: ────────────────────────────────────────────────────────────────
4:43:53 PM:
4:43:53 PM: No Next.js cache to restore.
4:43:53 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
4:43:53 PM:
4:43:53 PM: (@netlify/plugin-nextjs onPreBuild completed in 25ms)
4:43:53 PM:
4:43:53 PM: 2. build.command from netlify.toml
4:43:53 PM: ────────────────────────────────────────────────────────────────
4:43:53 PM:
4:43:53 PM: $ remix build
4:43:54 PM: Building Remix app in production mode...
4:43:54 PM: marked is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
Built in 332ms
4:43:54 PM:
4:43:54 PM: (build.command completed in 1.2s)
4:43:54 PM:
4:43:54 PM: 3. @netlify/plugin-nextjs (onBuild event)
4:43:54 PM: ────────────────────────────────────────────────────────────────
4:43:54 PM:
4:43:54 PM:
4:43:54 PM: Plugin "@netlify/plugin-nextjs" failed
4:43:54 PM: ────────────────────────────────────────────────────────────────
4:43:54 PM:
4:43:54 PM: Error message
4:43:54 PM: Error: The directory "/opt/build/repo/public" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
4:43:54 PM: In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.
4:43:54 PM: If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true".
4:43:54 PM:
4:43:54 PM: Plugin details
4:43:54 PM: Package: @netlify/plugin-nextjs
4:43:54 PM: Version: 4.30.0
4:43:54 PM: Repository: git+https://github.com/netlify/next-runtime.git
4:43:54 PM: npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
4:43:54 PM: Report issues: https://github.com/netlify/next-runtime/issues
4:43:54 PM:
4:43:54 PM: Error location
4:43:54 PM: In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app and package.json
4:43:54 PM:
4:43:54 PM: Resolved config
4:43:54 PM: build:
4:43:54 PM: command: remix build
4:43:54 PM: commandOrigin: config
4:43:54 PM: environment:
4:43:54 PM: - NEXT_PRIVATE_TARGET
4:43:54 PM: publish: /opt/build/repo/public
4:43:54 PM: publishOrigin: config
4:43:54 PM: functionsDirectory: /opt/build/repo/netlify/functions
4:43:54 PM: headers:
4:43:55 PM: - for: /build/*
values:
Cache-Control: public, max-age=31536000, s-maxage=31536000
headersOrigin: config
plugins:
- inputs: {}
origin: ui
package: '@netlify/plugin-nextjs'
redirects:
- from: /*
status: 200
to: /.netlify/functions/server
redirectsOrigin: config
Caching artifacts
4:43:55 PM: Started saving node modules
4:43:55 PM: Finished saving node modules
4:43:55 PM: Started saving build plugins
4:43:55 PM: Finished saving build plugins
4:43:55 PM: Started saving pip cache
4:43:55 PM: Finished saving pip cache
4:43:55 PM: Started saving emacs cask dependencies
4:43:55 PM: Finished saving emacs cask dependencies
4:43:55 PM: Started saving maven dependencies
4:43:55 PM: Finished saving maven dependencies
4:43:55 PM: Started saving boot dependencies
4:43:55 PM: Finished saving boot dependencies
4:43:55 PM: Started saving rust rustup cache
4:43:55 PM: Finished saving rust rustup cache
4:43:55 PM: Started saving go dependencies
4:43:55 PM: Finished saving go dependencies
4:43:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:43:56 PM: Failing build: Failed to build site
4:43:56 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
4:43:56 PM: Finished processing build request in 43.196s