5

I updated like this, found here

On Linux/Mac: npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save

When I remove node_modules and then npm install I get this,

WARNING in ./~/@angular/core/@angular/core.es5.js 5889:15-36 Critical dependency: the request of a dependency is an expression

Maybe this will help someone help me. It appears to be an issue with ES5?

Current errors in console.

enter image description here

Background

My project was working fine till I upgraded to Angular 4 last night. Now when I click on a link instead of loading the module (I am lazy loading) it tells me it cannot find the module.

Eror

ZoneAwareError {__zone_symbol__error: Error: Uncaught (in promise): Error: Cannot find module './benefits/benefits.module'. Error: Cannot ……}

Has anyone else shared this situation or have any clue how to fix this or even what to do to go about troubleshooting it? I thought there were no breaking changes in Angular 4?

Code Examples

package.json

{
  "name": "my-web-application",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
"private": true,
  "dependencies": {
    "@angular/animations": "^4.0.0",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/platform-server": "^4.0.0",
    "@angular/router": "^4.0.0",
    "angular2-jwt": "^0.1.28",
    "angular2-signaturepad": "^2.2.0",
    "auth0-lock": "^10.5.0",
    "core-js": "^2.4.1",
    "ng2-bootstrap": "^1.3.3",
    "ng2-charts": "^1.5.0",
    "ng2-toasty": "^2.5.0",
    "rxjs": "^5.2.0",
    "typescript": "^2.2.1",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.32.3",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0-beta.4",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.2.1"
  }
Alireza
  • 100,211
  • 27
  • 269
  • 172
wuno
  • 9,547
  • 19
  • 96
  • 180

1 Answers1

2

I came across some of the errors that you have pictured while upgrading to Angular 4.0:

Critical dependency: The request of the dependency is an expression.

Updating angluar-cli to latest solved that for me:

  1. Stop ng serve (if running).
  2. npm install @angular/cli@latest --save-dev
  3. ng serve

Hopefully, this fixes your zone.js issue as well (keep me posted, please).

The warning:

The <template> element is deprecated. Use <ng-template> instead...

is most likely caused by a library (possibly ng2-bootstrap, ng2-charts, or ng2-toasty?) that's using the deprecated template syntax (or you are in your code), so you may want to try to upgrade those as well -- if there is a newer version. I also got this deprecation warning, but I have a dependency that still hasn't been updated to 4.0, so I'm living with it for the next few days.

Note: I wasn't a big fan of those upgrade instructions as following them verbatim (like I originally did, without paying attention) on some projects gives you both dependencies and devDependencies that reference to different versions of the same lib. For example, you now have two versions of @angular/compiler-cli referenced in your package.json: 4.0 and 2.4.

Update for Completeness

Unfortunately, in wuno's case, to complete the upgrade, he had to go as far as:

  1. Create a new project.
  2. Update it.
  3. Replace the src directory with the one from his existing project.
  4. npm install and update package.json with his extra packages.

Per his final comment:

I had to create a new project, update it, replace the src directory with the one from my existing project then npm install and update package.json with my extra packages.

We never quite found out what was causing the issue that forced him to re-create the project in his particular case, but upgrading CLI ultimately fixed the issue in the original question.

Community
  • 1
  • 1
Steve
  • 11,596
  • 7
  • 39
  • 53
  • G yes I was thinking that would solve it as well. But it did not solve it for me. – wuno Mar 27 '17 at 23:50
  • @wuno Are you still experiencing all of the same warnings/errors or have some been cleared up after the CLI update? – Steve Mar 28 '17 at 00:02
  • Well I just realized my problem now is I cant get ng serve to run since I updated. I get Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (/Users/wuno/Dropbox/google/devops/node/riverwalk-web-application/node_modules/angular-cli/tasks/serve.js:22:61) at /Users/wuno/Dropbox/google/devops/node/riverwalk-web-application/node_modules/angular-cli/commands/serve.run.js:22:22 at process._tickCallback (internal/process/next_tick.js:103:7) – wuno Mar 28 '17 at 00:03
  • @wuno If you haven't seen this yet, it may be helpful: https://github.com/angular/angular-cli/issues/4736 Check for the leading "." In the file name of angular-cli.json. It changed in later versions of CLI. – Steve Mar 28 '17 at 00:07
  • Hey man I updated angular cli globally and locally and could not get the project to run. So I created a new project with ng new and the package.json file shows,"angular-cli": "1.0.0-beta.28.3",, So now my project is running with no errors, "@angular/common": "^2.3.1", But I thought the current version of angular cli was 1.0.0 ?? Do you see what I mean? My plan was to start upgrade process with angular cli already upgraded to see if that helps, but the version of angular cli in package.json does not seem to be recent. – wuno Mar 28 '17 at 00:21
  • OK so it compiles with only one error now, ERROR in ./src/app/contract/contract.component.ts Module not found: Error: Can't resolve '@angular/forms/src/model I am hoping if I clear this it will run. but I did not read anything about forms changing in angular 4. Did you see anything about this anywhere? import { VALID } from "@angular/forms/src/model"; Is causing the error. – wuno Mar 28 '17 at 00:35
  • Yes that is how i have been importing VALID to check for VALID in my form. It works fine till I upgraded. But I cant find any reference of this online. – wuno Mar 28 '17 at 00:47
  • https://www.insight.io/github.com/angular/angular/blob/g3_v2_0/modules/@angular/forms/src/model.ts – wuno Mar 28 '17 at 00:51
  • Weirdly I check for the file and it does Exist... also I can open it and see VALID defined inside of it... /** * Indicates that a FormControl is valid, i.e. that no errors exist in the input value. */ export declare const VALID = "VALID"; /** – wuno Mar 28 '17 at 01:13
  • Unfortunately, I haven't worked with ngForms that much, so I don't think I'd be too useful here, but might I suggest commenting that code out temporarily (if possible) to see if ng serve builds and runs before going any deeper in that rabbit hole. It would suck to fix that issue just to find out that this was all for nothing. – Steve Mar 28 '17 at 01:20
  • Ya good point. I think it will work. Thanks I will accept your answer give me 5 minutes. – wuno Mar 28 '17 at 01:22
  • Ok your right man it worked. It was a little more to it. I had to create a new project, update it, replace the src directory with the one from my existing project then npm install and update package.json with my extra packages. But good call bro and thanks. The VALID thing is a different issue obviously. I just don't understand cause there were not supposed to be any breaking changes. I suggest maybe you add my steps, but it is obviously up to you! Have a good night man! – wuno Mar 28 '17 at 01:28
  • For me the UI framework PrimeNG was the problem: [PrimeNG routing issue](https://github.com/primefaces/primeng/issues/2420#issuecomment-291116384) – Brampage Apr 04 '17 at 11:02