8

I have following js file (non ES6 file): (Other questions on SO, are about importing a ES6 type module, but here I am looking for importing a non-ES6 type module using import syntax.

== abc.js

module.exports = {
  checkSomething: function(a,b) {
     console.log("Checked");
   }
}

Now I want this to import in my some other file, using "import" syntax.

import abc from './abc';

Is that possible to do that?

NS: My project is currently mix of ES6 and non ES6 codes. So, I am able to use import with ES6 kind of modules, so was wondering if I can do same for above case.

kaounKaoun
  • 601
  • 1
  • 9
  • 21
  • You need to use `babel`. – Nandu Kalidindi Feb 08 '18 at 06:23
  • I am already using babel and able to import the modules which are writted in ES6. But some of the files (like above) are non-es6 type file. So I am trying to import that non-es6 file into my new file (which I am writing in ES6 type) – kaounKaoun Feb 08 '18 at 06:38

1 Answers1

-2

It means you are using ES6 in your code so you can do it easily. If an error occurs during use of Import then use babel-script npm.

Setu Modi
  • 100
  • 8