PLEASE help us help you by writing a good post!
My Netlify site name is boring-torvalds-ee9036.
I’m building and app with svelte-kit. The adapter for svelte-kit specifically indicates that svelte-kit won’t build with Node 12.16. So I have included a .nvmrc with 14 in it and I have attempted to set a NODE_VERSION envar to 14.
It appears from the logs that Node v12.16.3 is being used.
What am I doing wrong?
robhicks:
NODE_VERSION envar to 14
Just to check, you have specified NODE_VERSION
as v14.17.1
(or whichever minor/patch version you wish to use)?
I have successful set the NODE_VERSION
environment variable via the Netlify UI and had it picked up while using the latest build image in a test I have just finished.
Hi @robhicks ,
Your latest logs suggest: Netlify App , that you’ve got this part working. Is that the case?
No, my builds are still failing. I have set the NODE_VERSION envar to 14.17.5.
The build fails when it gets to setting up functions.
Packaging Functions from .netlify/functions-internal directory:
3:18:21 PM: - __render.js
3:18:21 PM:
3:18:23 PM:
3:18:23 PM: ────────────────────────────────────────────────────────────────
3:18:23 PM: Internal error during "Functions bundling"
3:18:23 PM: ────────────────────────────────────────────────────────────────
3:18:23 PM:
3:18:23 PM: Error message
3:18:23 PM: Error: readdirp: root argument is required. Usage: readdirp(root, options)
3:18:23 PM:
3:18:23 PM: Error location
3:18:23 PM: During Functions bundling
3:18:23 PM: at readdirp (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:262:11)
Thanks for your help!
Can you share your full deploy log @robhicks
Yes, here’s a complete log.
3:17:42 PM: Build ready to start
3:17:44 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
3:17:44 PM: build-image tag: v4.3.0
3:17:44 PM: buildbot version: 0f2f658d862cfe72bae7cc05c6a8de0426a5a0e2
3:17:44 PM: Fetching cached dependencies
3:17:44 PM: Starting to download cache of 114.9MB
3:17:45 PM: Finished downloading cache in 858.898509ms
3:17:45 PM: Starting to extract cache
3:17:49 PM: Finished extracting cache in 3.9175729s
3:17:49 PM: Finished fetching cache in 4.814980539s
3:17:49 PM: Starting to prepare the repo for build
3:17:49 PM: Preparing Git Reference refs/heads/master
3:17:50 PM: Parsing package.json dependencies
3:17:51 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'packages/pwa/build' versus '/' in the Netlify UI
3:17:51 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus '' in the Netlify UI
3:17:51 PM: Starting build script
3:17:51 PM: Installing dependencies
3:17:51 PM: Python version set to 2.7
3:17:51 PM: Started restoring cached node version
3:17:54 PM: Finished restoring cached node version
3:17:54 PM: Attempting node version '14' from .nvmrc
3:17:54 PM: v14.17.5 is already installed.
3:17:54 PM: Now using node v14.17.5 (npm v6.14.14)
3:17:54 PM: Started restoring cached build plugins
3:17:54 PM: Finished restoring cached build plugins
3:17:55 PM: Attempting ruby version 2.7.2, read from environment
3:17:56 PM: Using ruby version 2.7.2
3:17:56 PM: Using PHP version 8.0
3:17:56 PM: Started restoring cached node modules
3:17:56 PM: Finished restoring cached node modules
3:17:57 PM: Installing NPM modules using NPM version 6.14.14
3:18:08 PM: > bufferutil@4.0.3 install /opt/build/repo/packages/pwa/node_modules/bufferutil
3:18:08 PM: > node-gyp-build
3:18:08 PM: > utf-8-validate@5.0.5 install /opt/build/repo/packages/pwa/node_modules/utf-8-validate
3:18:08 PM: > node-gyp-build
3:18:08 PM: > svelte-preprocess@4.8.0 postinstall /opt/build/repo/packages/pwa/node_modules/svelte-preprocess
3:18:08 PM: > echo "[svelte-preprocess] Don't forget to install the preprocessors packages that will be used: node-sass/sass, stylus, less, postcss & postcss-load-config, coffeescript, pug, etc..."
3:18:08 PM: [svelte-preprocess] Don't forget to install the preprocessors packages that will be used: node-sass/sass, stylus, less, postcss & postcss-load-config, coffeescript, pug, etc...
npm notice created a lockfile as package-lock.json. You should commit this file.
3:18:08 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/vite/node_modules/fsevents):
3:18:08 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
3:18:08 PM: npm WARN covid-tracker-pwa@0.0.1 No repository field.
3:18:08 PM: npm WARN covid-tracker-pwa@0.0.1 No license field.
3:18:08 PM: added 218 packages from 216 contributors, updated 1 package and audited 250 packages in 11.14s
3:18:09 PM: 29 packages are looking for funding
3:18:09 PM: run `npm fund` for details
3:18:09 PM: found 0 vulnerabilities
3:18:09 PM: NPM modules installed
3:18:09 PM: Started restoring cached go cache
3:18:09 PM: Finished restoring cached go cache
3:18:09 PM: go version go1.16.5 linux/amd64
3:18:09 PM: go version go1.16.5 linux/amd64
3:18:09 PM: Installing missing commands
3:18:09 PM: Verify run directory
3:18:10 PM:
3:18:10 PM: ────────────────────────────────────────────────────────────────
3:18:10 PM: Netlify Build
3:18:10 PM: ────────────────────────────────────────────────────────────────
3:18:10 PM:
3:18:10 PM: ❯ Version
3:18:10 PM: @netlify/build 18.7.2
3:18:10 PM:
3:18:10 PM: ❯ Flags
3:18:10 PM: baseRelDir: true
3:18:10 PM: buildId: 612956766bcc640008b665fc
3:18:10 PM: deployId: 612956766bcc640008b665fe
3:18:10 PM:
3:18:10 PM: ❯ Current directory
3:18:10 PM: /opt/build/repo/packages/pwa
3:18:10 PM:
3:18:10 PM: ❯ Config file
3:18:10 PM: /opt/build/repo/packages/pwa/netlify.toml
3:18:10 PM:
3:18:10 PM: ❯ Context
3:18:10 PM: production
3:18:10 PM:
3:18:10 PM: ────────────────────────────────────────────────────────────────
3:18:10 PM: 1. build.command from netlify.toml
3:18:10 PM: ────────────────────────────────────────────────────────────────
3:18:10 PM:
3:18:10 PM: $ npm run build
3:18:10 PM: > covid-tracker-pwa@0.0.1 build /opt/build/repo/packages/pwa
3:18:10 PM: > svelte-kit build
3:18:11 PM: vite v2.5.1 building for production...
3:18:11 PM: transforming...
3:18:14 PM: warn - You have enabled the JIT engine which is currently in preview.
3:18:14 PM: warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
3:18:15 PM: ✓ 98 modules transformed.
3:18:16 PM: rendering chunks...
3:18:20 PM: .svelte-kit/output/client/_app/assets/facebook-121851f1.svg 0.29 KiB
3:18:20 PM: .svelte-kit/output/client/_app/assets/github-7c0295c7.svg 0.79 KiB
3:18:20 PM: .svelte-kit/output/client/_app/assets/google-afeb7929.svg 0.56 KiB
3:18:20 PM: .svelte-kit/output/client/_app/assets/linkedin-4eae04cd.svg 0.41 KiB
3:18:20 PM: .svelte-kit/output/client/_app/assets/twitter-155c9af0.svg 0.64 KiB
3:18:20 PM: .svelte-kit/output/client/_app/manifest.json 3.24 KiB
3:18:20 PM: .svelte-kit/output/client/_app/pages/index.svelte-dd2171fe.js 0.95 KiB / brotli: 0.48 KiB
3:18:20 PM: .svelte-kit/output/client/_app/error.svelte-9f8f07b2.js 1.56 KiB / brotli: 0.64 KiB
3:18:20 PM: .svelte-kit/output/client/_app/pages/reset-password.svelte-2cc43942.js 4.49 KiB / brotli: 1.66 KiB
3:18:20 PM: .svelte-kit/output/client/_app/pages/info.svelte-5f1d6e20.js 0.32 KiB / brotli: 0.20 KiB
3:18:20 PM: .svelte-kit/output/client/_app/pages/__layout.svelte-b6161afe.js 12.56 KiB / brotli: 3.34 KiB
3:18:20 PM: .svelte-kit/output/client/_app/chunks/singletons-12a22614.js 0.05 KiB / brotli: 0.05 KiB
3:18:20 PM: .svelte-kit/output/client/_app/chunks/Icon-890cf716.js 3.77 KiB / brotli: 1.43 KiB
3:18:20 PM: .svelte-kit/output/client/_app/chunks/user-becb8480.js 0.33 KiB / brotli: 0.29 KiB
3:18:20 PM: .svelte-kit/output/client/_app/chunks/navigation-51f4a605.js 0.11 KiB / brotli: 0.10 KiB
3:18:20 PM: .svelte-kit/output/client/_app/start-f888f82c.js 18.53 KiB / brotli: 5.81 KiB
3:18:20 PM: .svelte-kit/output/client/_app/chunks/Paragraph-551746a5.js 2.13 KiB / brotli: 0.69 KiB
3:18:20 PM: .svelte-kit/output/client/_app/pages/sign-in.svelte-5348979c.js 12.52 KiB / brotli: 3.25 KiB
3:18:20 PM: .svelte-kit/output/client/_app/assets/start-464e9d0a.css 0.19 KiB / brotli: 0.12 KiB
3:18:20 PM: .svelte-kit/output/client/_app/assets/pages/__layout.svelte-7da8405d.css 12.18 KiB / brotli: 2.84 KiB
3:18:20 PM: .svelte-kit/output/client/_app/chunks/vendor-30e31228.js 68.82 KiB / brotli: 17.04 KiB
3:18:20 PM: vite v2.5.1 building SSR bundle for production...
3:18:20 PM: transforming...
3:18:21 PM: ✓ 43 modules transformed.
3:18:21 PM: rendering chunks...
3:18:21 PM: .svelte-kit/output/server/app.js 48.72 KiB
3:18:21 PM: Run npm run preview to preview your production build locally.
3:18:21 PM:
3:18:21 PM: > Using @sveltejs/adapter-netlify
3:18:21 PM: ✔ done
3:18:21 PM:
3:18:21 PM: (build.command completed in 11.2s)
3:18:21 PM:
3:18:21 PM: ────────────────────────────────────────────────────────────────
3:18:21 PM: 2. Functions bundling
3:18:21 PM: ────────────────────────────────────────────────────────────────
3:18:21 PM:
3:18:21 PM: Packaging Functions from .netlify/functions-internal directory:
3:18:21 PM: - __render.js
3:18:21 PM:
3:18:23 PM:
3:18:23 PM: ────────────────────────────────────────────────────────────────
3:18:23 PM: Internal error during "Functions bundling"
3:18:23 PM: ────────────────────────────────────────────────────────────────
3:18:23 PM:
3:18:23 PM: Error message
3:18:23 PM: Error: readdirp: root argument is required. Usage: readdirp(root, options)
3:18:23 PM:
3:18:23 PM: Error location
3:18:23 PM: During Functions bundling
3:18:23 PM: at readdirp (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:262:11)
3:18:23 PM: at /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:276:5
3:18:23 PM: at new Promise (<anonymous>)
3:18:23 PM: at Function.readdirpPromise [as promise] (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/readdirp/index.js:274:10)
3:18:23 PM: at hasFunctionRootFile (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:119:32)
3:18:23 PM: at lacksNodeModules (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:111:12)
3:18:23 PM: at getModuleNotFoundMessage (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:50:43)
3:18:23 PM: at getModuleNotFoundErrorObject (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:41:25)
3:18:23 PM: at getModuleNotFoundErrorFromZISI (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:91:10)
3:18:23 PM: at getModuleNotFoundError (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/error.js:27:31)
3:18:23 PM:
3:18:23 PM: Resolved config
3:18:23 PM: build:
3:18:23 PM: base: /opt/build/repo/packages/pwa
3:18:23 PM: command: npm run build
3:18:23 PM: commandOrigin: config
3:18:23 PM: environment:
3:18:23 PM: - NODE_VERSION
3:18:23 PM: publish: /opt/build/repo/packages/pwa/build
3:18:23 PM: publishOrigin: config
3:18:23 PM: redirects:
3:18:23 PM: - from: /*
status: 200
to: /.netlify/functions/__render
Caching artifacts
3:18:23 PM: Started saving node modules
3:18:23 PM: Finished saving node modules
3:18:23 PM: Started saving build plugins
3:18:23 PM: Finished saving build plugins
3:18:23 PM: Started saving pip cache
3:18:23 PM: Finished saving pip cache
3:18:23 PM: Started saving emacs cask dependencies
3:18:23 PM: Finished saving emacs cask dependencies
3:18:23 PM: Started saving maven dependencies
3:18:23 PM: Finished saving maven dependencies
3:18:23 PM: Started saving boot dependencies
3:18:24 PM: Finished saving boot dependencies
3:18:24 PM: Started saving rust rustup cache
3:18:24 PM: Finished saving rust rustup cache
3:18:24 PM: Started saving go dependencies
3:18:24 PM: Finished saving go dependencies
3:18:24 PM: Build failed due to an internal system error: Build script returned non-zero exit code: 4
3:18:24 PM: Creating deploy upload records
3:18:24 PM: Failing build: Failed to build site
3:18:24 PM: Failed during stage 'building site': Build script returned non-zero exit code: 4
3:18:24 PM: Finished processing build request in 39.898112676s
Hi @robhicks
Functions need a different environment variable AWS_LAMBDA_JS_RUNTIME
with the value nodejs14.x
. Could you try that?
I tried adding the AWS_LAMBDA_JS_RUNTIME envar but the build still failed with the same error message.
Hi @robhicks ,
Could you also try using esbuild
to bundle the functions?
You could do so by adding the following to your netlify.toml
:
[functions]
node_bundler = "esbuild"
1 Like
Thanks a lot! It solved my problem.