Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

globalThis.Request is not a constructor #47

Open
2 tasks done
CanRau opened this issue Sep 6, 2022 · 5 comments
Open
2 tasks done

globalThis.Request is not a constructor #47

CanRau opened this issue Sep 6, 2022 · 5 comments

Comments

@CanRau
Copy link

CanRau commented Sep 6, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

3.29.2

Plugin version

0.0.5

Node.js version

16.14.2

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

11.6.6

Description

[vite] Error when evaluating SSR module /context.ts:
TypeError: globalThis.Request is not a constructor
at /fastify-dx-react-ts/node_modules/ky/distribution/core/constants.js:6:26
at /fastify-dx-react-ts/node_modules/ky/distribution/core/constants.js:17:3
at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
at async nodeImport (/fastify-dx-react-ts/node_modules/fastify-vite/node_modules/vite/dist/node/chunks/dep-689425f3.js:724:749)
at async eval (/context.ts:3:31)
at async instantiateModule (/fastify-dx-react-ts/node_modules/fastify-vite/node_modules/vite/dist/node/chunks/dep-689425f3.js:722:2131)

Steps to Reproduce

Start from react-ts
Install missing dependencies vite & ky
run yarn build && yarn dev

Expected Behavior

Working starter

@tony-go
Copy link

tony-go commented Sep 16, 2022

I have the same issue, expect I didn't have to install vite & ky but history.

@tony-go
Copy link

tony-go commented Sep 16, 2022

I upgraded the node version to 18.x, and the issue disappeared. (Before that I was on v16.17.0 (lts))

@BlackYuzia
Copy link

I upgraded the node version to 18.x, and the issue disappeared. (Before that I was on v16.17.0 (lts))

So, min version for work is 18.x?

@tony-go
Copy link

tony-go commented Sep 18, 2022

I upgraded the node version to 18.x, and the issue disappeared. (Before that I was on v16.17.0 (lts))

So, min version for work is 18.x?

Don't know; @galvez will probably explain why, but maybe they develop with node 18 and will work on backward compat later.

@tony-go
Copy link

tony-go commented Sep 18, 2022

Just found this: https://github.com/es-shims/globalThis

Ky targets modern browsers and Deno. For older browsers, you will need to transpile and use a fetch polyfill and globalThis polyfill. For isomorphic needs (Node.js + browser, like SSR), check out ky-universal.

EDIT: I'll invest a bit this week to see If I can fix it myself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants