Home
Support Forums

First deploy failing - sveltekit project with atlas mongodb

I need advice to debug deploy Netlify App
I tried setting NODE_VERSION to 14 thinking it may be the issue. Not sure if it is. Looks like netlify build is still using 12?
Would appreciate some ideas of how to get my first deploy working.
Thanks

Deploy log…

10:50:22 PM: Build ready to start
10:50:24 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
10:50:24 PM: build-image tag: v4.3.0
10:50:24 PM: buildbot version: d2795bf5a96b85e585e90944f15f15381ce164a7
10:50:24 PM: Fetching cached dependencies
10:50:24 PM: Failed to fetch cache, continuing with build
10:50:24 PM: Starting to prepare the repo for build
10:50:24 PM: No cached dependencies found. Cloning fresh repo
10:50:24 PM: git clone GitHub - StapleIT/sveltekit-netlify-todos
10:50:25 PM: Preparing Git Reference refs/heads/main
10:50:25 PM: Parsing package.json dependencies
10:50:26 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: β€˜functions’ versus β€˜fucntions/’ in the Netlify UI
10:50:26 PM: Starting build script
10:50:26 PM: Installing dependencies
10:50:26 PM: Python version set to 2.7
10:50:27 PM: Downloading and installing node v14.17.5…
10:50:27 PM: Downloading https://nodejs.org/dist/v14.17.5/node-v14.17.5-linux-x64.tar.xz…
10:50:27 PM: Computing checksum with sha256sum
10:50:27 PM: Checksums matched!
10:50:30 PM: Now using node v14.17.5 (npm v6.14.14)
10:50:30 PM: Started restoring cached build plugins
10:50:30 PM: Finished restoring cached build plugins
10:50:30 PM: Attempting ruby version 2.7.2, read from environment
10:50:32 PM: Using ruby version 2.7.2
10:50:32 PM: Using PHP version 8.0
10:50:32 PM: Started restoring cached node modules
10:50:32 PM: Finished restoring cached node modules
10:50:32 PM: Installing NPM modules using NPM version 6.14.14
10:50:39 PM: > esbuild@0.12.22 postinstall /opt/build/repo/node_modules/esbuild
10:50:39 PM: > node install.js
10:50:40 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/vite/node_modules/fsevents):
10:50:40 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {β€œos”:β€œdarwin”,β€œarch”:β€œany”} (current: {β€œos”:β€œlinux”,β€œarch”:β€œx64”})
10:50:40 PM: npm WARN ~TODO~@0.0.1 No repository field.
10:50:40 PM: npm WARN ~TODO~@0.0.1 No license field.
10:50:40 PM: added 55 packages from 126 contributors and audited 56 packages in 6.875s
10:50:40 PM: 7 packages are looking for funding
10:50:40 PM: run npm fund for details
10:50:40 PM: found 0 vulnerabilities
10:50:40 PM: NPM modules installed
10:50:40 PM: Started restoring cached go cache
10:50:40 PM: Finished restoring cached go cache
10:50:41 PM: go version go1.16.5 linux/amd64
10:50:41 PM: go version go1.16.5 linux/amd64
10:50:41 PM: Installing missing commands
10:50:41 PM: Verify run directory
10:50:42 PM: ​
10:50:42 PM: ────────────────────────────────────────────────────────────────
10:50:42 PM: Netlify Build
10:50:42 PM: ────────────────────────────────────────────────────────────────
10:50:42 PM: ​
10:50:42 PM: ❯ Version
10:50:42 PM: @netlify/build 18.5.0
10:50:42 PM: ​
10:50:42 PM: ❯ Flags
10:50:42 PM: baseRelDir: true
10:50:42 PM: buildId: 61263c8e882282cb8aff61ad
10:50:42 PM: deployId: 61263c8e882282cb8aff61af
10:50:42 PM: ​
10:50:42 PM: ❯ Current directory
10:50:42 PM: /opt/build/repo
10:50:42 PM: ​
10:50:42 PM: ❯ Config file
10:50:42 PM: /opt/build/repo/netlify.toml
10:50:42 PM: ​
10:50:42 PM: ❯ Context
10:50:42 PM: production
10:50:42 PM: ​
10:50:42 PM: ────────────────────────────────────────────────────────────────
10:50:42 PM: 1. build.command from netlify.toml
10:50:42 PM: ────────────────────────────────────────────────────────────────
10:50:42 PM: ​
10:50:42 PM: $ npm run build
10:50:42 PM: > ~TODO~@0.0.1 build /opt/build/repo
10:50:42 PM: > svelte-kit build
10:50:43 PM: vite v2.5.1 building for production…
10:50:43 PM: transforming…
10:50:43 PM: 12:50:43 PM [vite-plugin-svelte] /opt/build/repo/src/routes/index.svelte:89:1 Unused CSS selector β€œ.welcome”
10:50:43 PM: 87: }
10:50:43 PM: 88:
10:50:43 PM: 89: .welcome {
10:50:43 PM: ^
10:50:43 PM: 90: position: relative;
10:50:43 PM: 91: width: 100%;
10:50:43 PM: 12:50:43 PM [vite-plugin-svelte] /opt/build/repo/src/routes/index.svelte:96:1 Unused CSS selector β€œ.welcome img”
10:50:43 PM: 94: }
10:50:43 PM: 95:
10:50:43 PM: 96: .welcome img {
10:50:43 PM: ^
10:50:43 PM: 97: position: absolute;
10:50:43 PM: 98: width: 100%;
10:50:43 PM: 12:50:43 PM [vite-plugin-svelte] /opt/build/repo/src/routes/completed/index.svelte:43:1 Unused CSS selector β€œ.welcome”
10:50:43 PM: 41: }
10:50:43 PM: 42:
10:50:43 PM: 43: .welcome {
10:50:43 PM: ^
10:50:43 PM: 44: position: relative;
10:50:43 PM: 45: width: 100%;
10:50:43 PM: 12:50:43 PM [vite-plugin-svelte] /opt/build/repo/src/routes/completed/index.svelte:50:1 Unused CSS selector β€œ.welcome img”
10:50:43 PM: 48: }
10:50:43 PM: 49:
10:50:43 PM: 50: .welcome img {
10:50:43 PM: ^
10:50:43 PM: 51: position: absolute;
10:50:43 PM: 52: width: 100%;
10:50:44 PM: βœ“ 23 modules transformed.
10:50:45 PM: rendering chunks…
10:50:46 PM: .svelte-kit/output/client/_app/assets/svelte-logo-87df40b8.svg 1.85 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-cyrillic-400-normal-046b609f.woff2 9.08 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-greek-ext-400-normal-8659ae46.woff2 7.85 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-greek-400-normal-1f8b3a07.woff2 10.48 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-latin-ext-400-normal-b6331a25.woff2 11.84 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-cyrillic-ext-400-normal-b3140dd3.woff2 16.11 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-latin-400-normal-a2f9dbe8.woff2 16.44 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/fira-mono-all-400-normal-0d19eb5d.woff 75.54 KiB
10:50:46 PM: .svelte-kit/output/client/_app/manifest.json 2.15 KiB
10:50:46 PM: .svelte-kit/output/client/_app/error.svelte-6276fb94.js 1.56 KiB / brotli: 0.64 KiB
10:50:46 PM: .svelte-kit/output/client/_app/pages/index.svelte-e13ca36f.js 2.99 KiB / brotli: 1.28 KiB
10:50:46 PM: .svelte-kit/output/client/_app/pages/__layout.svelte-fbd2138c.js 4.30 KiB / brotli: 1.47 KiB
10:50:46 PM: .svelte-kit/output/client/_app/pages/completed/index.svelte-c5603e72.js 1.96 KiB / brotli: 0.91 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/pages/completed/index.svelte-fa13c2ce.css 0.13 KiB / brotli: 0.08 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/start-61d1577b.css 0.16 KiB / brotli: 0.11 KiB
10:50:46 PM: .svelte-kit/output/client/_app/assets/pages/__layout.svelte-a06e2686.css 5.01 KiB / brotli: 1.34 KiB
10:50:46 PM: .svelte-kit/output/client/_app/chunks/vendor-d90f5863.js 7.78 KiB / brotli: 2.87 KiB
10:50:46 PM: .svelte-kit/output/client/_app/start-d6dcdb7e.js 17.91 KiB / brotli: 5.68 KiB
10:50:46 PM: vite v2.5.1 building SSR bundle for production…
10:50:46 PM: transforming…
10:50:46 PM: 12:50:46 PM [vite-plugin-svelte] /opt/build/repo/src/routes/index.svelte:89:1 Unused CSS selector β€œ.welcome”
10:50:46 PM: 87: }
10:50:46 PM: 88:
10:50:46 PM: 89: .welcome {
10:50:46 PM: ^
10:50:46 PM: 90: position: relative;
10:50:46 PM: 91: width: 100%;
10:50:46 PM: 12:50:46 PM [vite-plugin-svelte] /opt/build/repo/src/routes/index.svelte:96:1 Unused CSS selector β€œ.welcome img”
10:50:46 PM: 94: }
10:50:46 PM: 95:
10:50:46 PM: 96: .welcome img {
10:50:46 PM: ^
10:50:46 PM: 97: position: absolute;
10:50:46 PM: 98: width: 100%;
10:50:46 PM: 12:50:46 PM [vite-plugin-svelte] /opt/build/repo/src/routes/completed/index.svelte:43:1 Unused CSS selector β€œ.welcome”
10:50:46 PM: 41: }
10:50:46 PM: 42:
10:50:46 PM: 43: .welcome {
10:50:46 PM: ^
10:50:46 PM: 44: position: relative;
10:50:46 PM: 45: width: 100%;
10:50:46 PM: 12:50:46 PM [vite-plugin-svelte] /opt/build/repo/src/routes/completed/index.svelte:50:1 Unused CSS selector β€œ.welcome img”
10:50:46 PM: 48: }
10:50:46 PM: 49:
10:50:46 PM: 50: .welcome img {
10:50:46 PM: ^
10:50:46 PM: 51: position: absolute;
10:50:46 PM: 52: width: 100%;
10:50:46 PM: βœ“ 23 modules transformed.
10:50:46 PM: rendering chunks…
10:50:46 PM: .svelte-kit/output/server/app.js 38.66 KiB
10:50:46 PM: Run npm run preview to preview your production build locally.
10:50:46 PM:
10:50:46 PM: > Using @sveltejs/adapter-netlify
10:50:46 PM: No publish directory specified in netlify.toml, using default
10:50:49 PM: :heavy_check_mark: done
10:50:49 PM: ​
10:50:49 PM: (build.command completed in 7.1s)
10:50:49 PM: ​
10:50:49 PM: ────────────────────────────────────────────────────────────────
10:50:49 PM: 2. Functions bundling
10:50:49 PM: ────────────────────────────────────────────────────────────────
10:50:49 PM: ​
10:50:49 PM: The Netlify Functions setting targets a non-existing directory: functions
10:50:49 PM: ​
10:50:49 PM: Packaging Functions from .netlify/functions-internal directory:
10:50:49 PM: - __render.js
10:50:49 PM: ​
10:50:52 PM: ​
10:50:52 PM: ────────────────────────────────────────────────────────────────
10:50:52 PM: Dependencies installation error
10:50:52 PM: ────────────────────────────────────────────────────────────────
10:50:52 PM: ​
10:50:52 PM: Error message
10:50:52 PM: A Netlify Function failed to require one of its dependencies.
10:50:52 PM: Please make sure it is present in the site’s top-level β€œpackage.json”.​
10:50:52 PM: In file β€œ/opt/build/repo/.netlify/functions-internal/__render.js”
10:50:52 PM: Cannot find module β€˜bson-ext’
10:50:52 PM: Require stack:
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/main.js
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/commands/get.js
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js
10:50:52 PM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js
10:50:52 PM: ​
10:50:52 PM: Resolved config
10:50:52 PM: build:
10:50:52 PM: command: npm run build
10:50:52 PM: commandOrigin: config
10:50:52 PM: environment:
10:50:52 PM: - NODE_VERSION
10:50:52 PM: publish: /opt/build/repo/build
10:50:52 PM: publishOrigin: ui
10:50:52 PM: functionsDirectory: /opt/build/repo/functions
10:50:52 PM: redirects:
10:50:53 PM: - from: /* status: 200 to: /.netlify/functions/__renderCaching artifacts
10:50:53 PM: Started saving node modules
10:50:53 PM: Finished saving node modules
10:50:53 PM: Started saving build plugins
10:50:53 PM: Finished saving build plugins
10:50:53 PM: Started saving pip cache
10:50:53 PM: Finished saving pip cache
10:50:53 PM: Started saving emacs cask dependencies
10:50:53 PM: Finished saving emacs cask dependencies
10:50:53 PM: Started saving maven dependencies
10:50:53 PM: Finished saving maven dependencies
10:50:53 PM: Started saving boot dependencies
10:50:53 PM: Finished saving boot dependencies
10:50:53 PM: Started saving rust rustup cache
10:50:53 PM: Finished saving rust rustup cache
10:50:53 PM: Started saving go dependencies
10:50:53 PM: Finished saving go dependencies
10:50:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:50:56 PM: Creating deploy upload records
10:50:56 PM: Failing build: Failed to build site
10:50:56 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
10:50:56 PM: Finished processing build request in 31.915773794s

Believe you need to remove the unused .welcome classes in src/routes/index.svelte and src/routes/completed/index.svelte.

You also have a typo in the netilfy.toml you have

publich = "build/"

instead of

publish = "build/"

(I’ve done the same thing myself.)

Build still failed though:

> svelte-kit build
> (node:1357) ExperimentalWarning: The ESM module loader is experimental.
> The requested module 'svelte-hmr' does not provide an export named 'createMakeHot'

This I have not found an answer for.

Thanks for your time in getting this far

I fixed what you suggested and I get different error when build fails? This is same error I was getting originally. Looks like its missing β€˜bson-ext’ whatever that is.

6:07:58 PM: ────────────────────────────────────────────────────────────────
6:07:58 PM: Dependencies installation error
6:07:58 PM: ────────────────────────────────────────────────────────────────
6:07:58 PM: ​
6:07:58 PM: Error message
6:07:58 PM: A Netlify Function failed to require one of its dependencies.
6:07:58 PM: Please make sure it is present in the site’s top-level β€œpackage.json”.
​
6:07:58 PM: In file β€œ/opt/build/repo/.netlify/functions-internal/__render.js”
6:07:58 PM: Cannot find module β€˜bson-ext’
6:07:58 PM: Require stack:

From what I can find, it is used by mongodb which is in your dependencies. Try adding it as a dependency too.

1 Like

Ok, I’ll try that. Thanks

I added that to dependencies and then kept adding dependencies as it threw them up (5 in all). Eventually it published! It doesn’t work as it does locally, but we’re getting there one step at a time. Thanks for you help.

2 Likes

If you are having more luck building locally, you might like to check out Netlify CLI which will enable you to build on your machine and deploy to Netlify.

Yes, I might check that out. The deploy from github on Netlfy seems to be breaking the mongodb fetch requests. The app works (can see screens and can navigate to routes), but todos aren’t created, read or updated as they should be.

OMG it works! Someone on Sveltekit discord showed me that there was a misunderstanding in my code which blocked the endpoints from sending/receiving to/from mongodb (but doesn’t in local dev). Deleted one line and it works! Thanks for your help.

2 Likes