I have got this node server and a bunch of JS classes in my js directory. I want to create a file called "exports.js" that exports all the classes required by server (using exports.Classname = class notation). However, the problem is that exports.js doesn't have access to the classes. I was wondering what's the correct syntax for importing the whole ES6 class in another file. So far I have tried following with no luck:
//I want to import User class from User.js
import "./User.js";
import "User";
import "./User";
Any help would be much appreciated.
Note: Not that it makes any difference but please note that I am using Babel transpiler.
// user.js
class user{
...
}
export default user
// another js
import user from './user.js'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With