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'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.