0

I want to import a module file from app.component.ts in an Angular project

import('./file.mjs').then(...)

but file.mjs will be existing in runtime only and not available at the compile time

I don't want to load the file as a json content so I won't use httpClient

I also tried to make it a dynamic import

let path = 'file.js'
import(path)

but I got the error Error: Cannot find module 'file.js' file.js is existing in the public folder and can be accessed in the browser via http://localhost:4200/file.js

helpful resources

I already searched for a proper solution and read some answers without the luck

Dynamically importing modules at runtime with Angular 14

Error importing external angular module at runtime

Sh eldeeb
  • 1,589
  • 3
  • 18
  • 41

0 Answers0