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.

After compiling fresh does not run: ReferenceError: React is not defined after compilation

See original GitHub issue

Create a new app

deno run -A -r https://fresh.deno.dev newapp

then

deno compile --import-map=import_map.json -o newapp -A main.ts

Result (when you try to load the page)

An error occured during route handling or page rendering.

ReferenceError: React is not defined
    at Object.Home (/denoapp/compapp/routes/index.tsx:3:5)
    at https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:1626
    at E (https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:1653)
    at E (https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:1729)
    at E (https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:1729)
    at E (https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:1729)
    at E (https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:1729)
    at q (https://esm.sh/v95/preact-render-to-string@5.2.4/X-ZS8q/deno/preact-render-to-string.js:12:316)
    at realRender (https://deno.land/x/fresh@1.1.1/src/server/render.ts:109:20)
    at Object.render (https://deno.land/x/fresh@1.1.1/src/server/render.ts:128:13)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lucacasonatocommented, Sep 21, 2022

Yes, you can not currently use deno compile with fresh applications.

0reactions
barcellos-pedrocommented, Nov 16, 2022

I hope it works soon, or maybe we could have a workaround

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: React is not defined - Stack Overflow
Possible reasons are 1. you didn't load React.JS into your page, 2. you loaded it after the above script into your page.
Read more >
"Uncaught ReferenceError: moment is not defined" using NPM
I installed Moment.js using npm: npm install moment. I'd now like to compile it using npm run dev to replace a version I...
Read more >
Uncaught ReferenceError: bsCustomFileInput is not defined, M
js file and got error during compile. Frankly I doubt this will work at all. Changing bootstrap.js is just such an uncommon solution......
Read more >
uncaught referenceerror: global is not defined react - You.com
The solution is to either remove this piece of configuration (so React will be bundled with your javascript) or load the React framework...
Read more >
jsconfig.json Reference - Visual Studio Code
Tip: Do not be confused by compilerOptions , since no actual compilation is required for JavaScript. This attribute exists because jsconfig.json is a...
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