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.

Class does not work

See original GitHub issue

This is the code i am using

class Task {
  constructor() {}
}

console.log("Loaded class_test.js");

module.exports = { Task };

I am compiling the code with bytenode using this command "bytenode -c ./test_area/class_test.js

And when running this loader file:

const { Task } = require("./class_test.loader");

const t = new Task();

I get this error:

const t = new Task();
          ^

TypeError: Task is not a constructor
    at Object.<anonymous> (C:\Users\gade1\WebstormProjects\nike-gen\test_area\bytenode_task_test.js:3:11)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

But when running the non compiled version:

const { Task } = require("./class_test");

const t = new Task();

It works just fine. I have already read the known limitations, and i can not find any others having the same problem.

Node: v13.13.0 Bytenode: 1.2.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
christopherGrcommented, Jun 11, 2021

Hello,

I am sorry for the inconvenience… you 're right, it was my fault… Thank you for this awesome module!

1reaction
OsamaAbbascommented, Apr 9, 2021

I guess you need to require the .jsc file directly, not the *.loader.js file. The loader file is meant to be as your entry script or so.

const { Task } = require('./class_test.jsc');

const t = new Task();
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Class not working? - css - Stack Overflow
I'm trying to change the text color in a <p> to gray. I thought doing something like <p class="gray">content</p> and p. gray {...
Read more >
not() - CSS: Cascading Style Sheets - MDN Web Docs
The :not() CSS pseudo-class represents elements that do not match a list of selectors. Since it prevents specific items from being selected, ...
Read more >
addClass and removeClass in jQuery - not removing class
I'm trying to do something very simple. Basically I have a clickable div 'hot spot', when you click that it fills the screen...
Read more >
.removeClass() | jQuery API Documentation
removeClass() method manipulated the className property of the selected elements, not the class attribute. Once the property was changed, it was the browser ......
Read more >
custom class does not work - Mendix Forum
I am using Mendix 8.2.2 version and created “Mendix\UICHECK\theme\styles\web\sass\app\customwidgets\temp.scss” and register file to ...
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