zmbq
zmbq

Reputation: 39013

Can't create an Angular 5 project using angular-cli

I'm trying to create a new Angular 5 project. I've installed @angular/cli version 1.6.3 and typed:

ng new project --routing

After everything has been installed I did:

cd project
ng build

And got the following errors:

Module build failed: Error: d:...\project\src\main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

Module build failed: Error: d:...\project\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

There are a couple of discussions about this on the Angular github page, but other than saying this has been resolved, or pointing to an issue where there where ts files in node_modules - it was not helpful.

We're using Windows 10 here.

EDIT: the tsconfig files are (there are two):

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

The other (src/tsconfig.app.json):

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

These were both created by ng new.

Upvotes: 4

Views: 1741

Answers (2)

zmbq
zmbq

Reputation: 39013

Oh dear, I forgot to answer this question! It was answered in the Angular github a long time ago.

In Angular 5 you need to add --preserve-symlinks to both ng build and ng serve.

In Angular 6 you can no longer do that, and instead you need to add

 "preserveSymlinks": true,

to angular.json, you put it under architect/build/options of your project.

Upvotes: 1

Nadhir Falta
Nadhir Falta

Reputation: 5257

Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine.

Upvotes: 0

Related Questions