How to make an import works in js file

(chrisxiao) #1

Environment: VS Code.
I have a tester.js as following:
“use strict”;
import without from ‘lodash’;
function Tester ()
{
// var output = without([1, 2, 3], 1);
// console.log(output);
console.log(“tester is called!”);
}
in a html file, I have
< script src=“tester.js”> < /script>
< scrip t>
var tester = new Tester();
< /script>

The run will shows error:
ReferenceError: Tester is not defined

If I comment out the import line in tester.js, I got correct print out: tester is called!

0 Likes

(John Gee) #2

(This isn’t about npm so I have moved to #community:javascript. Good luck with answers!)

0 Likes