I have a problem with using continuous deployment for my project. Each time I push to master, the build fails. It is also important to note that the deployment fails if I attempt to trigger it via the UI. The only way I can successfully deploy my site live is via the Netlify CLI. Part of me is thinking that this is an issue of compatibility (or incompatibility, rather) between Vite and Netlify.
At first, my project was structured so that the package.json of the project was not in the root directory. But now it is, so I cannot figure out why the build is still failing via the UI or when I push my master branch.
Lastly, in the debug log, this line(s) particularly sticks out to me:
[vite]: Rollup failed to resolve import "ohmyfetch" from "node_modules/@nuxtjs/sanity/dist/runtime/client.mjs".
11:00:53 PM: This is most likely unintended because it can break your application at runtime.
11:00:53 PM: If you do want to externalize this module explicitly add it to
11:00:53 PM: `build.rollupOptions.external`
I find it bizzare because I have @nuxtjs/sanity installed,
My project structure, debug log and package.json are included below.
Any help would be massively appreciated.
Project structure
.
βββ app.vue
βββ assets
βββ components
βββ dist -> /home/rabuttsurwa96/Documents/Web Development/Freelance/Win PreOwned Cars/winpre-cars/frontend/.output/public
βββ .gitignore
βββ layouts
βββ .netlify
βββ netlify.toml
βββ .nuxt
βββ nuxt.config.ts
βββ .output
βββ package.json
βββ package-lock.json
βββ pages
βββ README.md
βββ sanity.json
βββ tsconfig.json
Deploy log
11:00:19 PM: build-image version: 1ca34a93198b041e44214013884c57d146a23fed (focal)
11:00:19 PM: build-image tag: v4.16.4
11:00:19 PM: buildbot version: 30bb0dbce9c066d58cbd3a36ad34f8c91a4777a3
11:00:19 PM: Fetching cached dependencies
11:00:19 PM: Failed to fetch cache, continuing with build
11:00:19 PM: Starting to prepare the repo for build
11:00:19 PM: No cached dependencies found. Cloning fresh repo
11:00:19 PM: git clone --filter=blob:none --no-checkout git@github.com:GillyRabutTsurwa/winpre-cars-frontend
11:00:20 PM: Preparing Git Reference refs/heads/master
11:00:21 PM: Parsing package.json dependencies
11:00:22 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: '.output/public' versus 'dist' in the Netlify UI
11:00:23 PM: Starting build script
11:00:23 PM: Installing dependencies
11:00:23 PM: Python version set to 2.7
11:00:23 PM: v16.19.0 is already installed.
11:00:23 PM: Now using node v16.19.0 (npm v8.19.3)
11:00:23 PM: Enabling Node.js Corepack
11:00:23 PM: Started restoring cached build plugins
11:00:23 PM: Finished restoring cached build plugins
11:00:24 PM: Attempting Ruby version 2.7.2, read from environment
11:00:24 PM: Using Ruby version 2.7.2
11:00:24 PM: Using PHP version 8.0
11:00:24 PM: Started restoring cached corepack dependencies
11:00:24 PM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
11:00:24 PM: Finished restoring cached corepack dependencies
11:00:25 PM: No npm workspaces detected
11:00:25 PM: Started restoring cached node modules
11:00:25 PM: Finished restoring cached node modules
11:00:25 PM: Bypassing sha validation. Running pre & post install scripts
11:00:25 PM: Installing npm packages using npm version 8.19.3
11:00:44 PM: npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
11:00:44 PM: npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
11:00:44 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
11:00:47 PM: > postinstall
11:00:47 PM: > nuxt prepare
11:00:47 PM: [log] Nuxi 3.0.0
11:00:48 PM: [info] [@nuxtjs/sanity] Enabling minimal client as @sanity/client is not installed.
11:00:48 PM: [info] [@nuxtjs/sanity] Running with Sanity project 2cbrvq50 (production).
11:00:48 PM: [success] Types generated in .nuxt
11:00:48 PM: added 667 packages, and audited 668 packages in 23s
11:00:48 PM: 98 packages are looking for funding
11:00:48 PM: run `npm fund` for details
11:00:48 PM: found 0 vulnerabilities
11:00:48 PM: npm packages installed
11:00:48 PM: Started restoring cached go cache
11:00:48 PM: Finished restoring cached go cache
11:00:48 PM: go version go1.19.5 linux/amd64
11:00:48 PM: Detected 1 framework(s)
11:00:48 PM: "nuxt" at version "3.0.0"
11:00:48 PM: Installing missing commands
11:00:48 PM: Verify run directory
11:00:48 PM: Section completed: initializing
11:00:50 PM: β
11:00:50 PM: Netlify Build
11:00:50 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
11:00:50 PM: β
11:00:50 PM: β― Version
11:00:50 PM: @netlify/build 29.5.1
11:00:50 PM: β
11:00:50 PM: β― Flags
11:00:50 PM: baseRelDir: true
11:00:50 PM: buildId: 63cf57c923776100096e4e48
11:00:50 PM: deployId: 63cf57c923776100096e4e4a
11:00:50 PM: β
11:00:50 PM: β― Current directory
11:00:50 PM: /opt/build/repo
11:00:50 PM: β
11:00:50 PM: β― Config file
11:00:50 PM: /opt/build/repo/netlify.toml
11:00:50 PM: β
11:00:50 PM: β― Context
11:00:50 PM: production
11:00:50 PM: β
11:00:50 PM: 1. Build command from Netlify app
11:00:50 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
11:00:50 PM: β
11:00:50 PM: $ nuxt generate
11:00:50 PM: [log] Nuxi 3.0.0
11:00:50 PM: [log] Nuxt 3.0.0 with Nitro 1.0.0
11:00:50 PM: [warn] Using experimental payload extraction for full-static output. You can opt-out by setting `experimental.payloadExtraction` to `false`.
11:00:50 PM: [info] [@nuxtjs/sanity] Enabling minimal client as @sanity/client is not installed.
11:00:50 PM: [info] [@nuxtjs/sanity] Running with Sanity project 2cbrvq50 (production).
11:00:53 PM: [error] [vite]: Rollup failed to resolve import "ohmyfetch" from "node_modules/@nuxtjs/sanity/dist/runtime/client.mjs".
11:00:53 PM: This is most likely unintended because it can break your application at runtime.
11:00:53 PM: If you do want to externalize this module explicitly add it to
11:00:53 PM: `build.rollupOptions.external`
11:00:53 PM: [error] [vite]: Rollup failed to resolve import "ohmyfetch" from "node_modules/@nuxtjs/sanity/dist/runtime/client.mjs".
11:00:53 PM: This is most likely unintended because it can break your application at runtime.
11:00:53 PM: If you do want to externalize this module explicitly add it to
11:00:53 PM: `build.rollupOptions.external`
11:00:53 PM: This is most likely unintended because it can break your application at runtime.
11:00:53 PM: If you do want to externalize this module explicitly add it to
11:00:53 PM: `build.rollupOptions.external`
11:00:53 PM: at onRollupWarning (node_modules/vite/dist/node/chunks/dep-5605cfa4.js:45832:19)
11:00:53 PM: at onwarn (node_modules/vite/dist/node/chunks/dep-5605cfa4.js:45603:13)
11:00:53 PM: at Object.onwarn (node_modules/rollup/dist/es/shared/rollup.js:23263:13)
11:00:53 PM: at ModuleLoader.handleResolveId (node_modules/rollup/dist/es/shared/rollup.js:22158:26)
11:00:53 PM: at node_modules/rollup/dist/es/shared/rollup.js:22119:26
11:00:53 PM: β
11:00:53 PM: "build.command" failed
11:00:53 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
11:00:53 PM: β
11:00:53 PM: Error message
11:00:53 PM: Command failed with exit code 1: nuxt generate (https://ntl.fyi/exit-code-1)
11:00:53 PM: β
11:00:53 PM: Error location
11:00:53 PM: In Build command from Netlify app:
11:00:53 PM: nuxt generate
11:00:53 PM: β
11:00:53 PM: Resolved config
11:00:53 PM: build:
11:00:53 PM: command: nuxt generate
11:00:53 PM: commandOrigin: ui
11:00:53 PM: publish: /opt/build/repo/.output/public
11:00:54 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:00:53 PM: publishOrigin: config
11:00:53 PM: functionsDirectory: /opt/build/repo/netlify/functions
11:00:53 PM: Caching artifacts
11:00:53 PM: Started saving node modules
11:00:53 PM: Finished saving node modules
11:00:53 PM: Started saving build plugins
11:00:53 PM: Finished saving build plugins
11:00:53 PM: Started saving pip cache
11:00:53 PM: Finished saving pip cache
11:00:53 PM: Started saving emacs cask dependencies
11:00:53 PM: Finished saving emacs cask dependencies
11:00:53 PM: Started saving maven dependencies
11:00:53 PM: Finished saving maven dependencies
11:00:53 PM: Started saving boot dependencies
11:00:53 PM: Finished saving boot dependencies
11:00:53 PM: Started saving rust rustup cache
11:00:53 PM: Finished saving rust rustup cache
11:00:53 PM: Started saving go dependencies
11:00:53 PM: Finished saving go dependencies
11:00:54 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:00:54 PM: Failing build: Failed to build site
11:00:54 PM: Finished processing build request in 35.12s
package.json
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"nuxt": "3.0.0"
},
"dependencies": {
"@nuxtjs/sanity": "^1.5.0",
"@sanity/cli": "^2.35.0",
"sass": "^1.56.1",
"sass-loader": "^13.2.0"
}
}