GithubHelp home page GithubHelp logo

The import @lit-protocol/lit-node-client doesn't work in Sveltekit. If you try to import this library in a Sveltekit project, the app throws a 500 error with ReferenceError: global/process is not defined about js-sdk HOT 2 CLOSED

lit-protocol avatar lit-protocol commented on July 20, 2024
The import @lit-protocol/lit-node-client doesn't work in Sveltekit. If you try to import this library in a Sveltekit project, the app throws a 500 error with ReferenceError: global/process is not defined

from js-sdk.

Comments (2)

Ansonhkg avatar Ansonhkg commented on July 20, 2024

hi @ChristianOConnor

Thanks for providing the demo app; that allowed me to quickly to check the problem!

The error occurs I believe is because Svelte doesn't apply automatic polyfills, unlike react, nextjs . These latter frameworks use bundlers like webpack,which automatically polyfill these variables to make the code work in the browser.

For now, you'll need to manually polyfill it in your vite.config.ts file. I've added this issue to our to-do list and hopefully, we'll have it fixed in upcoming patches.

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
	plugins: [sveltekit()],
	define: {
		'process.env.NODE_DEBUG': 'false',
		'window.global': 'globalThis'
	}
});

from js-sdk.

ChristianOConnor avatar ChristianOConnor commented on July 20, 2024

Perfect! This worked thanks!

from js-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.