question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adapter-netlify: should it be possible to build/deploy from CLI?

See original GitHub issue

Describe the bug

When using the adapter-netlify adapter in my project, none of the svelte-kit nor netlify CLI build commands work.

However when the project is pushed to github, netlify is able to build and run the app.

Locally there appears to be an error originating from within the adapter-netlify codebase…

Logs

npm run build

> myproject@0.0.1 build /Projects/myproject
> svelte-kit build

vite v2.3.4 building for production...
✓ 15 modules transformed.
.svelte-kit/output/client/_app/manifest.json                           1.48kb
.svelte-kit/output/client/_app/layout.svelte-73d54427.js               0.49kb / brotli: 0.29kb
.svelte-kit/output/client/_app/pages/index.svelte-a3df9afb.js          0.79kb / brotli: 0.42kb
.svelte-kit/output/client/_app/error.svelte-2beaf441.js                1.19kb / brotli: 0.57kb
.svelte-kit/output/client/_app/assets/start-a8cd1609.css               0.16kb / brotli: 0.10kb
.svelte-kit/output/client/_app/pages/brand/[slug].svelte-41705c82.js   1.68kb / brotli: 0.78kb
.svelte-kit/output/client/_app/chunks/vendor-4e0cc74e.js               5.13kb / brotli: 2.01kb
.svelte-kit/output/client/_app/start-de7fd6e7.js                       17.42kb / brotli: 5.56kb
vite v2.3.4 building SSR bundle for production...
✓ 12 modules transformed.
.svelte-kit/output/server/app.js   11.27kb

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-netlify
> Cannot read property 'rimraf' of undefined
TypeError: Cannot read property 'rimraf' of undefined
    at adapt (file:///Projects/myproject/node_modules/@sveltejs/adapter-netlify/index.js:15:10)
    at adapt (file:///Projects/myproject/node_modules/@sveltejs/kit/dist/chunks/index5.js:322:8)
    at file:///Projects/myproject/node_modules/@sveltejs/kit/dist/cli.js:616:11

To Reproduce

  1. Setup new svelte-kit@next app
  2. Install the adapter-netlify adapter
  3. Run npm run build or netlify build commands

Expected behavior

Build should execute without error and place the resulting files in the svelte-kit output directory as normal.

Stacktraces If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread’s readability:

Stack trace

0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli ‘/Users/me/.nvm/versions/node/v14.16.0/bin/node’, 1 verbose cli ‘/Users/me/.nvm/versions/node/v14.16.0/bin/npm’, 1 verbose cli ‘run’, 1 verbose cli ‘build’ 1 verbose cli ] 2 info using npm@6.14.11 3 info using node@v14.16.0 4 verbose run-script [ ‘prebuild’, ‘build’, ‘postbuild’ ] 5 info lifecycle altbrand@0.0.1~prebuild: altbrand@0.0.1 6 verbose lifecycle altbrand@0.0.1~prebuild: unsafe-perm in lifecycle true 7 verbose lifecycle altbrand@0.0.1~prebuild: PATH: /Users/me/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Projects/myproject/node_modules/.bin:/Users/me/.rbenv/shims:/Users/me/.yarn/bin:/Users/me/.nvm/versions/node/v14.16.0/bin:/usr/local/opt/mysql@5.7/bin:/Users/me/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/me/development/flutter/bin 8 verbose lifecycle altbrand@0.0.1~prebuild: CWD: /Projects/myproject 9 silly lifecycle altbrand@0.0.1~prebuild: Args: [ ‘-c’, ‘node scripts/preBuild.js’ ] 10 silly lifecycle altbrand@0.0.1~prebuild: Returned: code: 0 signal: null 11 info lifecycle altbrand@0.0.1~build: altbrand@0.0.1 12 verbose lifecycle altbrand@0.0.1~build: unsafe-perm in lifecycle true 13 verbose lifecycle altbrand@0.0.1~build: PATH: /Users/me/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Projects/myproject/node_modules/.bin:/Users/me/.rbenv/shims:/Users/me/.yarn/bin:/Users/me/.nvm/versions/node/v14.16.0/bin:/usr/local/opt/mysql@5.7/bin:/Users/me/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/me/development/flutter/bin 14 verbose lifecycle altbrand@0.0.1~build: CWD: /Projects/myproject 15 silly lifecycle altbrand@0.0.1~build: Args: [ ‘-c’, ‘svelte-kit build’ ] 16 silly lifecycle altbrand@0.0.1~build: Returned: code: 1 signal: null 17 info lifecycle altbrand@0.0.1~build: Failed to exec build script 18 verbose stack Error: altbrand@0.0.1 build: svelte-kit build 18 verbose stack Exit status 1 18 verbose stack at EventEmitter.<anonymous> (/Users/me/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16) 18 verbose stack at EventEmitter.emit (events.js:315:20) 18 verbose stack at ChildProcess.<anonymous> (/Users/me/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 18 verbose stack at ChildProcess.emit (events.js:315:20) 18 verbose stack at maybeClose (internal/child_process.js:1048:16) 18 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) 19 verbose pkgid altbrand@0.0.1 20 verbose cwd /Projects/myproject 21 verbose Darwin 20.4.0 22 verbose argv “/Users/me/.nvm/versions/node/v14.16.0/bin/node” “/Users/me/.nvm/versions/node/v14.16.0/bin/npm” “run” “build” 23 verbose node v14.16.0 24 verbose npm v6.14.11 25 error code ELIFECYCLE 26 error errno 1 27 error altbrand@0.0.1 build: svelte-kit build 27 error Exit status 1 28 error Failed at the altbrand@0.0.1 build script. 28 error This is probably not a problem with npm. There is likely additional logging output above. 29 verbose exit [ 1, true ]

Information about your SvelteKit Installation:

Diagnostics

System: OS: macOS 11.3 CPU: (12) x64 Intel® Core™ i9-8950HK CPU @ 2.90GHz Memory: 3.02 GB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node Yarn: 1.22.0 - /usr/local/bin/yarn npm: 6.14.11 - ~/.nvm/versions/node/v14.16.0/bin/npm Browsers: Brave Browser: 90.1.24.82 Chrome: 90.0.4430.212 Safari: 14.1 npmPackages: @sveltejs/kit: next => 1.0.0-next.109 svelte: ^3.34.0 => 3.38.2

Browser: n/a this is a command line problem

Adapter: adapter-netlify

Severity Moderate. While build/deploy works via github CI, it does not work locally.

Additional context

// svelte.config.js

import preprocess from 'svelte-preprocess';
import adapter from '@sveltejs/adapter-netlify';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://github.com/sveltejs/svelte-preprocess
	// for more information about preprocessors
	preprocess: preprocess(),

	kit: {
		adapter: adapter(),

		// hydrate the <div id="svelte"> element in src/app.html
		target: '#svelte'
	}
};

export default config;

# netlify.toml
[build]
  command = "npm run build"
  publish = ".svelte-kit/build/"
  functions = "functions/"

[dev]
  framework = "svelte"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
disbeliefcommented, May 31, 2021

Thank you @jthegedus that was the problem and upgrading both @sveltejs/kit and @sveltejs/adapter-netlify to the latest versions solved it.

0reactions
jlkiricommented, Jun 13, 2021

I tried the concrete latest versions and this error disappeared! (maybe because next which I was using was pointing at smth else)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to deploy an Astro site - Netlify
Open up your terminal, and run the following command depending on your preferred package manager. ... The Astro CLI will guide you through...
Read more >
Publish .NET apps with the .NET CLI - Microsoft Learn
Learn to publish a .NET application using the .NET CLI commands.
Read more >
the requested module 'node-fetch' does not provide an export ...
The requested module 'svelte-hmr' does not provide an export named 'createMakeHot' appears in Netlify and the build / deploy fails.
Read more >
vercel | Ship | Command Line Interface library - kandi
Implement vercel with how-to, Q&A, fixes, code snippets. kandi ratings - Medium support, No Bugs, No Vulnerabilities. Permissive License, Build available.
Read more >
adapter-netlify: should it be possible to build/deploy from CLI?
Describe the bug When using the adapter-netlify adapter in my project, none of the svelte-kit nor netlify CLI build commands work.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found