Build failing after switching to vite (from create react app)

Hi, I would love to know why it is failing all the time. I have no linting errors/warnings, netlify build locally builds fine. The only issues are the chunk size warning and the use client issue, which both have to do with switching to Vite. Are these causing the build to fail?
Any help would be amazing as I’m pretty stuck. Thank you.

Deploy ID: 644828887b573a000852d6db

Deploys from github.com/Bponthemove/market_garden

Last Broken Deploy:
09/07 8:59:21 PM: buildId: 64ab116cecf1e80008b8b356

Last Successful Deploy:
25/04 8:23:11 PM: buildId: 644828887b573a000852d6d9

@Bponthemove warnings are treated as errors by default.

If you suspect warnings are causing your build to fail, you could change your build command to CI= npm run build (if it isn’t already what you have set).

Thanks Nathan, I tried that a few deploys ago but it didn’t make a difference. Tried it again tonight, but logs the same as before.
I put the logs in here in case it helps.

8:13:23 PM: build-image version: 1ae4e4d7d5e3544ab1eb7f270391cdbb47c1e1e5 (focal)
8:13:23 PM: buildbot version: 07d3aed5474bb03935df0405b4a4ae7c66557a4a
8:13:23 PM: Building without cache
8:13:23 PM: Starting to prepare the repo for build
8:13:24 PM: No cached dependencies found. Cloning fresh repo
8:13:24 PM: git clone --filter=blob:none git$github.com:Bponthemove/market_garden
8:13:24 PM: Preparing Git Reference refs/heads/main
8:13:27 PM: Starting to install dependencies
8:13:27 PM: Python version set to 3.8
8:13:27 PM: Attempting Ruby version 2.7.2, read from environment
8:13:27 PM: Using Ruby version 2.7.2
8:13:28 PM: Started restoring cached go cache
8:13:28 PM: Finished restoring cached go cache
8:13:28 PM: go version go1.19.10 linux/amd64
8:13:28 PM: Using PHP version 8.0
8:13:29 PM: Downloading and installing node v16.20.1…
8:13:29 PM: Downloading nodejs.org/dist/v16.20.1/node-v16.20.1-linux-x64.tar.xz…
8:13:29 PM: Computing checksum with sha256sum
8:13:29 PM: Checksums matched!
8:13:31 PM: Now using node v16.20.1 (npm v8.19.4)
8:13:31 PM: Enabling Node.js Corepack
8:13:31 PM: Started restoring cached build plugins
8:13:31 PM: Finished restoring cached build plugins
8:13:31 PM: Started restoring cached corepack dependencies
8:13:31 PM: Finished restoring cached corepack dependencies
8:13:31 PM: No npm workspaces detected
8:13:31 PM: Started restoring cached node modules
8:13:31 PM: Finished restoring cached node modules
8:13:32 PM: Installing npm packages using npm version 8.19.4
8:13:40 PM: npm WARN deprecated urix$0.1.0:
8:13:41 PM: npm WARN deprecated string-similarity$4.0.4: Package no longer supported.
8:13:41 PM: npm WARN deprecated source-map-url$0.4.1:
8:13:41 PM: npm WARN deprecated source-map-resolve$0.5.3:
8:13:41 PM: npm WARN deprecated resolve-url$0.2.1:
8:14:02 PM: added 1950 packages, and audited 1951 packages in 31s
8:14:02 PM: 292 packages are looking for funding
8:14:02 PM: run npm fund for details
8:14:03 PM: 26 vulnerabilities (21 moderate, 5 high)
8:14:03 PM: To address issues that do not require attention, run:
8:14:03 PM: npm audit fix
8:14:03 PM: To address all issues (including breaking changes), run:
8:14:03 PM: npm audit fix --force
8:14:03 PM: Run npm audit for details.
8:14:03 PM: npm packages installed
8:14:03 PM: Install dependencies script success
8:14:03 PM: Starting build script
8:14:04 PM: Detected 1 framework(s)
8:14:04 PM: vite at version 4.3.9
8:14:04 PM: Section completed: initializing
8:14:06 PM: ​
8:14:06 PM: Netlify Build
8:14:06 PM: ────────────────────────────────────────────────────────────────
8:14:06 PM: ​
8:14:06 PM: ❯ Version
8:14:06 PM: $netlify/build 29.15.3
8:14:06 PM: ​
8:14:06 PM: ❯ Flags
8:14:06 PM: baseRelDir: true
8:14:06 PM: buildId: 64ac5851d902ef280541957e
8:14:06 PM: deployId: 64ac5851d902ef2805419580
8:14:06 PM: ​
8:14:06 PM: ❯ Current directory
8:14:06 PM: /opt/build/repo
8:14:06 PM: ​
8:14:06 PM: ❯ Config file
8:14:06 PM: /opt/build/repo/netlify.toml
8:14:06 PM: ​
8:14:06 PM: ❯ Context
8:14:06 PM: production
8:14:06 PM: ​
8:14:06 PM: Build command from Netlify app
8:14:06 PM: ────────────────────────────────────────────────────────────────
8:14:06 PM: ​
8:14:06 PM: $ CI= npm run build
8:14:06 PM: > market_garden$0.1.0 build
8:14:06 PM: > vite build
8:14:06 PM: vite v4.3.9 building for production…
8:14:06 PM: transforming…
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useQueries.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useQuery.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/QueryClientProvider.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/Hydrate.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/QueryErrorResetBoundary.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useIsFetching.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useIsMutating.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useMutation.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useInfiniteQuery.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/isRestoring.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query-devtools/build/lib/index.mjs was ignored.
8:14:06 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/reactBatchedUpdates.mjs was ignored.
8:14:07 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useSyncExternalStore.mjs was ignored.
8:14:07 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/errorBoundaryUtils.mjs was ignored.
8:14:07 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query/build/lib/useBaseQuery.mjs was ignored.
8:14:07 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query-devtools/build/lib/devtools.mjs was ignored.
8:14:08 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query-devtools/build/lib/theme.mjs was ignored.
8:14:08 PM: Module level directives cause errors when bundled, use client in node_modules/$tanstack/react-query-devtools/build/lib/Explorer.mjs was ignored.
8:14:11 PM: βœ“ 1248 modules transformed.
8:14:13 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
8:14:11 PM: rendering chunks…
8:14:11 PM: computing gzip size…
8:14:11 PM: dist/index.html 2.10 kB β”‚ gzip: 1.01 kB
8:14:11 PM: dist/assets/index-5265c558.css 0.29 kB β”‚ gzip: 0.23 kB
8:14:11 PM: dist/assets/web-vitals-60d3425a.js 4.31 kB β”‚ gzip: 1.68 kB
8:14:11 PM: dist/assets/index-e0f26fb2.js 1,161.99 kB β”‚ gzip: 325.31 kB
8:14:11 PM:
8:14:11 PM: (!) Some chunks are larger than 500 kBs after minification. Consider:
8:14:11 PM: - Using dynamic import() to code-split the application
8:14:11 PM: - Use build.rollupOptions.output.manualChunks to improve chunking: Configuration Options | Rollup
8:14:11 PM: - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
8:14:11 PM: βœ“ built in 5.41s
8:14:11 PM: ​
8:14:11 PM: (build.command completed in 5.8s)
8:14:11 PM: ​
8:14:11 PM: Functions bundling
8:14:11 PM: ────────────────────────────────────────────────────────────────
8:14:11 PM: ​
8:14:11 PM: Packaging Functions from netlify/functions directory:
8:14:11 PM: - stripeAddProduct.ts
8:14:11 PM: - stripeDeleteProduct.ts
8:14:11 PM: - stripePayCart.ts
8:14:11 PM: - stripeUpdateProduct.ts
8:14:11 PM: ​
8:14:12 PM: ​
8:14:12 PM: (Functions bundling completed in 201ms)
8:14:12 PM: ​
8:14:12 PM: Deploy site
8:14:12 PM: ────────────────────────────────────────────────────────────────
8:14:12 PM: ​
8:14:12 PM: Section completed: deploying
8:14:12 PM: ​
8:14:12 PM: Configuration error
8:14:12 PM: ────────────────────────────────────────────────────────────────
8:14:12 PM: ​
8:14:12 PM: Error message
8:14:12 PM: Deploy did not succeed: Deploy directory β€˜build’ does not exist
8:14:12 PM: ​
8:14:12 PM: Resolved config
8:14:12 PM: build:
8:14:12 PM: command: CI= npm run build
8:14:12 PM: commandOrigin: ui
8:14:12 PM: environment:
8:14:12 PM: - CI
8:14:12 PM: - VITE_APP_FIREBASE_API_KEY
8:14:12 PM: - VITE_APP_FIREBASE_APP_ID
8:14:12 PM: - VITE_APP_FIREBASE_AUTH_DOMAIN
8:14:12 PM: - VITE_APP_FIREBASE_MESSAGING_SENDER_ID
8:14:12 PM: - VITE_APP_FIREBASE_PROJECT_ID
8:14:12 PM: - VITE_APP_FIREBASE_STORAGE_BUCKET
8:14:12 PM: - VITE_APP_STRIPE_PUBLISHABLE_KEY
8:14:12 PM: - VITE_APP_STRIPE_SECRET_KEY
8:14:12 PM: publish: /opt/build/repo/build
8:14:12 PM: publishOrigin: ui
8:14:12 PM: functionsDirectory: /opt/build/repo/netlify/functions
8:14:12 PM: Caching artifacts
8:14:12 PM: Started saving node modules
8:14:12 PM: Finished saving node modules
8:14:12 PM: Started saving build plugins
8:14:12 PM: Finished saving build plugins
8:14:12 PM: Started saving corepack cache
8:14:12 PM: Finished saving corepack cache
8:14:12 PM: Started saving pip cache
8:14:12 PM: Finished saving pip cache
8:14:12 PM: Started saving emacs cask dependencies
8:14:12 PM: Finished saving emacs cask dependencies
8:14:12 PM: Started saving maven dependencies
8:14:12 PM: Finished saving maven dependencies
8:14:12 PM: Started saving boot dependencies
8:14:12 PM: Finished saving boot dependencies
8:14:12 PM: Started saving rust rustup cache
8:14:12 PM: Finished saving rust rustup cache
8:14:12 PM: Started saving go dependencies
8:14:12 PM: Finished saving go dependencies
8:14:13 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:14:13 PM: Failing build: Failed to build site
8:14:14 PM: Finished processing build request in 50.335s

@Bponthemove As your build log shows, your error is at deployment:

8:14:12 PM: ​
8:14:12 PM: Section completed: deploying
8:14:12 PM: ​
8:14:12 PM: Configuration error
8:14:12 PM: ────────────────────────────────────────────────────────────────
8:14:12 PM: ​
8:14:12 PM: Error message
8:14:12 PM: Deploy did not succeed: Deploy directory β€˜build’ does not exist

You have your Publish directory set to build.

You don’t have a build directory.

Vite by default produces a dist directory.

You can run your npm run build command locally and see what it produces, if it’s a dist directory then change your Publish directory to dist.

Thanks Nathan! Don’t understand how I missed that​:face_with_open_eyes_and_hand_over_mouth:. Thanks for your time :+1:

1 Like

Glad you found your solution!