In general, I work in a PHPstorm compil via tsconfig.json

 { "compilerOptions": { "module": "commonjs", "sourceMap": true }, "files": [ "Main.ts" ] } 

File collects but writes the following

 "use strict"; var index_1 = require("../node_modules/typedi/src/index"); var CarFactory_1 = require("./CarFactory"); var Counter_1 = require("./Counter"); var carFactory = index_1.Container.get(CarFactory_1.CarFactory); carFactory.create(); var counter = index_1.Container.get(Counter_1.Counter); counter.increase(); counter.increase(); counter.increase(); console.log(counter.getCount()); //# sourceMappingURL=Main.js.map 

Browser naturally swears

require is not defined

How to be?

  • There is no require in the browser. Modules need to be assembled with something like a webpack or browserify - user207618
  • Thank you all earned - Serge Esmanovich

0