gramjs
gramjs copied to clipboard
ReferenceError: process is not defined
trafficstars
I'm attempting to import the client in a SvelteKit project and receive the error:
ReferenceError: process is not defined
at node_modules/.pnpm/[email protected]/node_modules/util/util.js (http://localhost:3000/node_modules/.vite/chunk-3JEY5UOV.js?v=c79871cd:1131:5)
at __require (http://localhost:3000/node_modules/.vite/chunk-OYVF2PGL.js?v=c79871cd:10:50)
at node_modules/.pnpm/[email protected]/node_modules/telegram/tl/api.js (http://localhost:3000/node_modules/.vite/chunk-3JEY5UOV.js?v=c79871cd:5507:23)
at __require (http://localhost:3000/node_modules/.vite/chunk-OYVF2PGL.js?v=c79871cd:10:50)
at node_modules/.pnpm/[email protected]/node_modules/telegram/tl/index.js (http://localhost:3000/node_modules/.vite/chunk-3JEY5UOV.js?v=c79871cd:36655:17)
at __require (http://localhost:3000/node_modules/.vite/chunk-OYVF2PGL.js?v=c79871cd:10:50)
at node_modules/.pnpm/[email protected]/node_modules/telegram/index.js (http://localhost:3000/node_modules/.vite/chunk-3JEY5UOV.js?v=c79871cd:35590:16)
at __require (http://localhost:3000/node_modules/.vite/chunk-OYVF2PGL.js?v=c79871cd:10:50)
at http://localhost:3000/node_modules/.vite/telegram.js?v=c79871cd:7:24
To reproduce quickly scaffold a new SvelteKit app and add the library:
pnpm init svelte@next integrate-sveltekit && \
cd integrate-sveltekit && pnpm i -D telegram
When prompted by the scaffolding tool enter:
- Template (Skeleton project)
- TypeScript (Y)
- ESLint (Y)
Add the following to src/routes/index.svelte:
<script lang="ts">
import { TelegramClient } from 'telegram';
</script>
And start the app and open it in a new browser tab:
pnpm run dev -- --open
You might need to modify your Rollup configuration to look like the Webpack configuration in the root folder of the repository. I don't know a lot about Rollup, it'll be an achievement if you make it work btw.
you could also just import it with