8

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.

1
  • Secondary comment. If there is an error for example "ERROR in Error encountered resolving symbol values statically" does the build process abort ? Commented Mar 10, 2017 at 18:50

8 Answers 8

5

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.

Sign up to request clarification or add additional context in comments.

Comments

5

I encountered the same problem. The solution for me was to look in the tsconfig.json file and remove dist from the excludes section. Then I ran ng build and the dist folder was generated and put into the project root directory.

Also look at your angular-cli.json file to see if the outdir field is writing to dist.

Comments

1

Also, perhaps the dist folder has actually been created (check in your Finder) but doesn't show in your text editor because, by default, your .gitignore file has /dist.

Comments

1

I solved this by adding a folder /dist manually, and run "ng build". So that I can see what is in there and copy things to upload to AWS S3.

Comments

1

Step 1 :- Go to angular.json and check for below line "outputPath": "../webapp",

Step 2 :- Redirect to the path which is mentioned inside the outputPath you will get the dist file.

Comments

1

The build folder will be listed in the angular.json file with parameter named outputPath. Just check the respective folder to get the production code.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "BuddyTranslator": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "./dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],
            ...

Here the directory name is dist. So, that the build files will be listed under dist folder in the source directory,

Comments

0

In my case, it was funny. I had opened a terminal(cmd) and distination was dist folder. So, the dist folder was locked. I closed the terminal and everything went OK.

Comments

0

Find and add this in angular.json file, worked for me, finally got my dist with data.

"build": {
  "options": {
    "outputPath": "dist"
  }
  ...
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.