Search code examples
angulargitignoreenvironmentapi-key

How to resolve reference error "src/environments/environment.ts' is not a module."


Hi I am trying to implement the solution to hide sensitive Information(for example GOOGLE_API_KEY)

To do this I have created environment.ts file and added to .gitignore section, as I don't want to push to Git but it is available during development in the local box.

Question: How do I make the reference working for import * as environment from '../../environments/environment.test' in different file.

for example: test.ts

Please help me how to overcome this?


Solution

  • You just import only the environment.ts is enough. When you serve or build your project. It'll have a configuration in angular.json to look for configuration file and replace it for you.

    For more information: angular guide