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.

Require is not defined in Playground

See original GitHub issue

Bug Report

variable run in server but error in Playground

image

should i change my code ?

Environment

OS: OSX 10.12.6 Node/npm version: Node 8.11.2/NPM 6.3.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zWingzcommented, Aug 15, 2018

error when defined variable outside Playground

const b = 1
<Playground>
  <div>{b}</div>
</Playground>

image

0reactions
pedronauckcommented, Aug 16, 2018

Unfortunately is not a good practice for webpack put require on playground scope, you can read this post to know more about that

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "require is not defined" in JavaScript / Node.js?
In our case, the error message is “require is not defined” which indicates the problem is with the variable or method named “require”....
Read more >
require is not defined? Node.js - javascript - Stack Overflow
require() is not a feature that is built into the browser. That is a specific feature of node.js, not of a browser. So,...
Read more >
ReferenceError: require is not defined in JavaScript - Stack Diary
The "ReferenceError: require is not defined" error occurs when the require function is used in a JavaScript file that is intended to be ......
Read more >
Getting issue in vite/packages/playground/ssr-vue/server.js ...
Describe the bug Getting issue in vite/packages/playground/ssr-vue/server.js ReferenceError: require is not defined I am using Vite, Vue 3, ...
Read more >
Use require() to Include External Modules - MongoDB
Require Native Modules; Require Non-Native Modules ... You can use the require() function in your MongoDB Playgrounds to include modules which exist in ......
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