find.js:2 Uncaught ReferenceError: exports is not defined

Viewed 1993

how can i use the list (that is named myjson) in other js file?!

exports is not defined...

the first line that is Object.defineProperty(exports, "__esModule", { value: true });

is originally not in here. But i added.

And still have this problem.

How can i use 'myjson' in other js file??

Object.defineProperty(exports, "__esModule", { value: true }); var
 dataone = document.querySelector('#dataone'); var datatwo =
 document.querySelector('#datatwo'); var datathree =
 document.querySelector('#datathree'); var datafour =
 document.querySelector('#datafour'); // var findingokay =
 document.querySelector('.findingokay');

 var data1 = 0; var data2 = 0; var data3 = 0; var data4 = 0;



 var myjson = [data1, data2, data3, data4]; exports.myjson = myjson;

enter image description here

Uncaught ReferenceError: exports isenter code here not defined at find.js:2

-



1 Answers

Use compilers like babel, browserify to make use of latest js features and these compilers will convert your code to browser supported js version.

Have a look at https://babeljs.io/

Related