Angular-cli: Can't create new Angular project with angular-cli

Created on 8 Jan 2018  Â·  12Comments  Â·  Source: angular/angular-cli

I've installed @angular/cli version 1.6.3 and then did:

ng new frontend --routing
cd frontend
ng build

I got an error saying main.ts and polyfills.ts are not included in tsconfig.json .

I've seen two issues on the matter, one was about ts placed in the wrong place, the other was closed as a duplicate of the first. This is clearly not the same case - I did not create any ts files, and all I need to do is run that series of commands and get the exact same behavior. This happens on several of our development machines (all with Windows 10)

Versions

Angular CLI: 1.6.3
Node: 8.9.3
OS: win32 x64
Angular: 5.1.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.3
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

Repro steps

    ng new frontend --routing
    cd frontend
    ng build

Observed behavior

The following errors:

ERROR in d:/chelem/ShalevItzkovitz/Interactions/frontend/src/main.ts
Module build failed: Error: d:\chelem\ShalevItzkovitz\Interactions\frontend\src\main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:653:23)
    at plugin.done.then (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous> @ multi ./src/main.ts

ERROR in d:/chelem/ShalevItzkovitz/Interactions/frontend/src/polyfills.ts
Module build failed: Error: d:\chelem\ShalevItzkovitz\Interactions\frontend\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (d:\chelem\ShalevItzkovitz\Interactions\frontendnode_modules\@ngtools\webpack\src\angular_compiler_plugin.js:653:23)
    at plugin.done.then (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtoolswebpack\src\loader.js:467:39)
    at <anonymous> @ multi ./src/polyfills.ts

Desired behavior

ng new should create a project that can be built and served.

more info 1 (urgent) bufix

All 12 comments

@zmbq just to confirm, you're saying that ng new does not create the TS files right? Can you show me the console output from running ng new appname please?

Yesterday I also saw an odd problem with a generator where files were not created on Windows 10. I'm guessing it's a similar problem, but seeing the log for ng new would help.

C:\Users\itay\sources\ShalevItzkovitz\Interactions [master] > ng new frontend --routing --style=scss
  create frontend/e2e/app.e2e-spec.ts (290 bytes)
  create frontend/e2e/app.po.ts (208 bytes)
  create frontend/e2e/tsconfig.e2e.json (235 bytes)
  create frontend/karma.conf.js (923 bytes)
  create frontend/package.json (1320 bytes)
  create frontend/protractor.conf.js (722 bytes)
  create frontend/README.md (1024 bytes)
  create frontend/tsconfig.json (363 bytes)
  create frontend/tslint.json (3040 bytes)
  create frontend/.angular-cli.json (1245 bytes)
  create frontend/.editorconfig (245 bytes)
  create frontend/.gitignore (516 bytes)
  create frontend/src/assets/.gitkeep (0 bytes)
  create frontend/src/environments/environment.prod.ts (51 bytes)
  create frontend/src/environments/environment.ts (387 bytes)
  create frontend/src/favicon.ico (5430 bytes)
  create frontend/src/index.html (295 bytes)
  create frontend/src/main.ts (370 bytes)
  create frontend/src/polyfills.ts (2405 bytes)
  create frontend/src/styles.scss (80 bytes)
  create frontend/src/test.ts (1085 bytes)
  create frontend/src/tsconfig.app.json (211 bytes)
  create frontend/src/tsconfig.spec.json (304 bytes)
  create frontend/src/typings.d.ts (104 bytes)
  create frontend/src/app/app-routing.module.ts (245 bytes)
  create frontend/src/app/app.module.ts (395 bytes)
  create frontend/src/app/app.component.html (1173 bytes)
  create frontend/src/app/app.component.spec.ts (1103 bytes)
  create frontend/src/app/app.component.ts (208 bytes)
  create frontend/src/app/app.component.scss (0 bytes)
Installing packages for tooling via yarn.
yarn install v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@angular/cli > @angular-devkit/schematics > @schematics/[email protected]" has unmet peer dependency "@angular-
devkit/[email protected]".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 64.65s.
Installed packages for tooling via yarn.
Directory is already under version control. Skipping initialization of git.
Project 'frontend' successfully created.

Here is the output of ng build:

C:\Users\itay\sources\ShalevItzkovitz\Interactions\frontend [master] > ng build
Date: 2018-01-09T13:00:45.702Z
Hash: a73c63c6ee645ae53d98
Time: 2180ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 867 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 892 bytes [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 3.02 kB [initial] [rendered]

ERROR in d:/chelem/ShalevItzkovitz/Interactions/frontend/src/main.ts
Module build failed: Error: d:\chelem\ShalevItzkovitz\Interactions\frontend\src\main.ts is missing from the TypeScript c
ompilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtools\webp
ack\src\angular_compiler_plugin.js:653:23)
    at plugin.done.then (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtools\webpack\src\loader.js:467
:39)
    at <anonymous>
 @ multi ./src/main.ts
ERROR in d:/chelem/ShalevItzkovitz/Interactions/frontend/src/polyfills.ts
Module build failed: Error: d:\chelem\ShalevItzkovitz\Interactions\frontend\src\polyfills.ts is missing from the TypeScr
ipt compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtools\webp
ack\src\angular_compiler_plugin.js:653:23)
    at plugin.done.then (d:\chelem\ShalevItzkovitz\Interactions\frontend\node_modules\@ngtools\webpack\src\loader.js:467
:39)
    at <anonymous>
 @ multi ./src/polyfills.ts

@zmbq and you don't have the src/main.ts file after ng new, correct?

@filipesilva , I do have src/main.ts . I'm attaching a file with the entire content of the directory created by ng new (I just removed node_modules from the zip file)

frontend.zip

I'm sorry but I cannot reproduce what you're seeing... I downloaded your file, ran npm install and then npm run ng -- build and it built correctly:

kamik@T460p MINGW64 D:/sandbox/frontend
$ npm run ng -- build

> [email protected] ng D:\sandbox\frontend
> ng "build"

Date: 2018-01-09T13:31:27.310Z
Hash: f520f53812d927e1da2e
Time: 7503ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 9.67 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 202 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.7 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.73 MB [initial] [rendered]

Do you have symlinks or juntions in that path? I'm looking at the log you posted and the error is shown in a different folder than the one you run the commands from.

If so then the bug you are running into is https://github.com/angular/angular-cli/issues/8603.

One of the directories there is indeed a junction. I tried running ng build –preserve-symlinks yesterday and it didn’t make any difference. For some really impossible to comprehend reason, today it does work with –preserve-symlinks…

So it is the same bug. Thanks and sorry.

From: Filipe Silva [mailto:[email protected]]
Sent: Tuesday, January 9, 2018 3:34 PM
To: angular/angular-cli angular-cli@noreply.github.com
Cc: Itay Zandbank itay@chelem.co.il; Mention mention@noreply.github.com
Subject: Re: [angular/angular-cli] Can't create new Angular project with angular-cli (#9129)

I'm sorry but I cannot reproduce what you're seeing... I downloaded your file, ran npm install and then npm run ng -- build and it built correctly:

kamik@T460p MINGW64 D:/sandbox/frontend
$ npm run ng -- build

[email protected] ng D:\sandbox\frontend
ng "build"

Date: 2018-01-09T13:31:27.310Z
Hash: f520f53812d927e1da2e
Time: 7503ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 9.67 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 202 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.7 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.73 MB [initial] [rendered]

Do you have symlinks or juntions in that path? I'm looking at the log you posted and the error is shown in a different folder than the one you run the commands from.

If so then the bug you are running into is #8603 https://github.com/angular/angular-cli/issues/8603 .

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/9129#issuecomment-356284858 , or mute the thread https://github.com/notifications/unsubscribe-auth/AAlkfuVTnDtITsJ5R3XmJG-Le-4bHBxbks5tI2rHgaJpZM4RWMh- . https://github.com/notifications/beacon/AAlkfgoe41IT4dNzz5-FKMzz1v96n_KFks5tI2rHgaJpZM4RWMh-.gif

Maybe at the time you had a version of Angular CLI with a bug that prevented it from working. I'll close as a duplicate of #8603 then.

It was definitely version 1.6.3, as well. Oh well.

I had this bug today, running with –preserve-symlinks worked but without it would not build. I was running with from windows cmd. I think there is still a problem.

I was having this same bug for a couple hours. I found out that I was in the wrong working directory.
my directory: ~/My Documents/Github/MyProject/client
correct directory: ~/Documents/Github/MyProject/client

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hareeshav picture hareeshav  Â·  3Comments

JanStureNielsen picture JanStureNielsen  Â·  3Comments

jbeckton picture jbeckton  Â·  3Comments

hartjo picture hartjo  Â·  3Comments

brtnshrdr picture brtnshrdr  Â·  3Comments