Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-cli not generating dist directory with ng build

Tags:

angular-cli

Here is what I have installed:

@angular/cli: 1.0.0-rc.1
node: 7.4.0
os: linux x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1

I have looked at this post Not generating dist folders , but I just want a dist directory generated so that I can link it with Express. The command I am using is

ng build --base-href /apply/

I understand with ng serve the files are created in memory. However I am not using ng serve. I have a Express static path

app.use('/', express.static(path.resolve('../../dist')));

Since the build command does not create the dist directory I cannot serve the angular application. The answer in the link (above) says to use the --watch argument. Why do I have to do that? Shouldn't ng build create the dist directory?

Am I missing something obvious. Any help is appreciated.

like image 889
user1315955 Avatar asked Feb 05 '23 22:02

user1315955


1 Answers

Here is what I have learned. The reason there was no dist directory being created was due to the fact that there was a compiling error (in older cli version this was not the case). The error was

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 79:22 in the original .ts file), resolving symbol AUTH_PROVIDERS in ...

I removed the dependency of AUTH_PROVIDERS from app_module.ts. Once this was done the project compiled ok.

like image 103
user1315955 Avatar answered Mar 05 '23 16:03

user1315955