I'm trying to import Angular environment.ts into a different module from the app.module, specifically:
- src (Folder)
- app (Folder)
- Service (Folder)
- service.module.ts (File) <-This is where I want to import the environment
- app.module.ts (File)
- Service (Folder)
- environment (Folder)
- environment.ts (File) <- File which I want to import
- app (Folder)
Inside app.module this works fine:
import { environment } from '../environments/environment';
Which doesn't work inside the service.module, I have also tried:
import { environment } from 'src/environments/environment'; import { environment } from '../environments/environment';
Any ideas of how can I make this work?
Best Answer
Based on your depiction of the filesystem, you need to go back up one more level.
Try
import { environment } from '../../environments/environment';
.