Angular-cli: I am on Angular 5 and CLI 1.5 and I get an error

Created on 3 Nov 2017  路  19Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular CLI: 1.5.0
Node: 9.0.0
OS: linux x64
Angular: 5.0.0
... common, compiler, compiler-cli, core, forms, http
... platform-browser, platform-browser-dynamic, router

@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.4.2
webpack: 3.8.1
node: 9.0.0
npm: 5.5.1

Repro steps.


I just build a webpack program and I get this error with @ngtools

The log given by the failure.

ERROR in ./test/angular-webpack/angular/bundle.aot.ts
Module not found: Error: Can't resolve './module.ngfactory' in '/home/patrikx3/Projects/angular5/corifeus-web5/test/angular-webpack/angular'
 @ ./test/angular-webpack/angular/bundle.aot.ts 8:25-54

ERROR in Error: Please update @angular/cli. Angular 5+ requires at least Angular CLI 1.5+
  at throwNotSupportedError (/home/patrikx3/Projects/angular5/corifeus-builder-angular5/node_modules/@angular/compiler-cli/src/ngtools_api.js:78:11)
  at Function.NgTools_InternalApi_NG_2.codeGen (/home/patrikx3/Projects/angular5/corifeus-builder-angular5/node_modules/@angular/compiler-cli/src/ngtools_api.js:31:15)
  at _donePromise.Promise.resolve.then (/home/patrikx3/Projects/angular5/corifeus-builder-angular5/node_modules/@ngtools/webpack/src/plugin.js:430:58)
  at <anonymous>:null:null
  at process._tickCallback (internal/process/next_tick.js:188:7)
  at Function.Module.runMain (module.js:684:11)
  at startup (bootstrap_node.js:191:16)
  at bootstrap_node.js:613:3


ERROR in /home/patrikx3/Projects/angular5/corifeus-web5/test/angular-webpack/angular/bundle.aot.ts (8,31): Cannot find module './module.ngfactory'.

Desired functionality.


I am on Angular CLI 1.5, why do I get this error that I am not on Angular 1.5???

Mention any other details that might be useful.

Most helpful comment

I faced this error after updating a non-CLI project to Angular 5 and @ngtools/webpack 1.8.0. I forgot to replace AotPlugin with AngularCompilerPlugin in my webpack config as described in the @ngtools/webpack README.md

By using AngularCompilerPlugin the error went away.

All 19 comments

Did you update both your @angular/cli reference under dev dependencies and your global cli install? I I think I got this error earlier when I hadn't done one or the other.

Try deleting the lock file and node modules then reinstall. Also make sure both global CLI and the project one are updated.

I have the same error. Tried deleting node-modules and lockfile. It did not help...

One of our developers got a similar problem at work today. The problem was due to the fact that he had upgraded his version of node to 8.xx. After uninstalling Node and installing the latest version of Node 6.xx the problem went away.

I upgraded to angular 5.0.0 and downgraded node to 7 and 6 but it did not work. Then I downgraded angular to 4.4.6 and got it working.

I receive the error when building with --prod flag (ionic), with will enable minify and aot

I faced this error after updating a non-CLI project to Angular 5 and @ngtools/webpack 1.8.0. I forgot to replace AotPlugin with AngularCompilerPlugin in my webpack config as described in the @ngtools/webpack README.md

By using AngularCompilerPlugin the error went away.

Yes, that's it , now it works!, THANKS!

Where is de path of this file, the webpack config?

I have the same problem ..

Please update @angular/cli. Angular 5+ requires at least Angular CLI 1.5+

@ionic/cli-utils  : 1.18.0
ionic (Ionic CLI) : 3.18.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 2.0.2
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 25.2.5
Node              : v6.9.0
npm               : 3.10.8
OS                : Windows 7

Environment Variables:

ANDROID_HOME : C:\Users\anton\AppData\Local\Android\sdk

Misc:

backend : pro

@thianlopezz If you don't find a webpack config in your source tree, then there are three options:

  • you use some framework or build tool other than angular-cli which hides the webpack config from you

    • in case you use angular-cli then it also hides the config from you but upgrading to [email protected] should work

  • you don't have a webpack-based build at all
  • you have a weird name for the config file

In the first case you may need to post an issue elsewhere, in the other two cases the problem is very special to your project and I can't help you with the infos you have exposed so far.

@klochko7 You're using Ionic. Maybe you should post your issue there.

I have the same problem with VS2017 ASP.NET Core + Angular 2 project. When I update the original project template to Angular 5.0.0 I get the above error. My versions:

PM> ng --version
_(fancy drawing removed)_
Angular CLI: 1.5.2
Node: 8.9.1
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, platform-server
... router, upgrade

_(some @ signs removed not shown properly)_
@angular/cli: 1.5.2
@angular/compiler-cli: 5.0.2
angular-devkit/build-optimizer: 0.0.33
angular-devkit/core: 0.0.20
angular-devkit/schematics: 0.0.36
ngtools/json-schema: 1.1.0
ngtools/webpack: 1.9.0-beta.2
schematics/angular: 0.1.5
typescript: 2.4.2
webpack-hot-middleware: 2.18.2
webpack-merge: 4.1.0
webpack: 2.5.1

PM> npm -g outdated
Package Current Wanted Latest Location
@angular/cli 1.5.2 1.5.3 1.5.3
firebase-tools 3.2.1 3.15.2 3.15.2

PM> npm --versions
...
npm: '5.5.1',

I have tried almost every possible scenario and combination of versions. This is where I stuck. I need to use angular 5 for this project. What did I miss?

@danielleiszen Do you have any link to that ASP.NET template, a repo or something alike? Your versions seem to be up-to-date.

Are @angular/cli AND @ngtools/webpack both a direct dependency of your project? Because if you use @angular/cli you usually don't need to install @ngtools/webpack yourself since its part of @angular/cli. Having both might be a sign that you have a custom webpack build. Then you should also have a webpack config and may need to adjust the webpack config like I described earlier.

@about-code Thanks for the answer. I replaced two instances of AotPlugin to AngularCompilerPlugin, and it seems to solve the issue. Thx.

for me as well @ngtools/webpack 1.8.2 was not work I had to use as well 1.8.0 and it works perfectly.

https://github.com/angular/angular-cli/issues/8525

@about-code I too am using ASP.NET Core 2.0's Angular template and upgraded from Angular 4 to Angular 5. I replaced two instances of AotPlugin in my wepack.config.js file with AngularCompilerPlugin to fix the problem. Thank you for pointing me in the right direction. I can't recall where I got the link from now, but anyone looking to do the same can go (https://long2know.com/2017/11/angular-5-0-released/) to see how it is done.

The error handling should be better.

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