I am using workspaces concept of angular latest version(>6).
The CLI can generate a project that is a library with a command like this:
ng generate library api
tsconfig.json of default app is like this
"paths": {
"env": ["src/environments"],
"api": [
"dist/api"
],
After that I created one service named ApiService in api library like this but it's not working
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from 'env';
@Injectable()
export class ApiService {
constructor(private http: HttpClient) {}
getApiUrl(){
console.log("Hello Api Url"+environment.api_url)
}
}
Returns error when I build api library using command ng build api
:
BUILD ERROR
error TS6059: File 'ROOT_APP_PATH/src/environments/environment.ts'
is not under 'rootDir' 'ROOT_APP_PATH\projects\api\src'.
'rootDir' is expected to contain all source files.
please help to resolve this error.
Thanks in Advance.