The ES6 way of require is import
. You can export
your class and import it somewhere else using import { ClassName } from 'path/to/ClassName'
syntax.
import fs from 'fs';
export default class Animal {
constructor(name){
this.name = name ;
}
print(){
console.log('Name is :'+ this.name);
}
}
import Animal from 'path/to/Animal.js';