angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ERROR in Cannot read property 'map' of undefined

Open odahcam opened this issue 8 years ago • 7 comments

Versions

$ ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.0-rc.10
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0-rc.6
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, platform-server
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.13
@angular-devkit/build-angular     0.5.13
@angular-devkit/build-optimizer   0.5.13
@angular-devkit/core              0.5.13
@angular-devkit/schematics        0.5.13
@angular/cdk                      6.0.0-rc.14
@angular/cli                      6.0.0-rc.10
@angular/compiler-cli             5.2.10
@angular/flex-layout              6.0.0-beta.15
@angular/language-service         5.2.10
@angular/material                 6.0.0-rc.14
@angular/pwa                      0.5.13
@ngtools/webpack                  6.0.0-rc.11
@schematics/angular               0.5.13
@schematics/update                0.5.13
rxjs                              6.0.0
typescript                        2.6.2
webpack                           4.6.0

Repro steps

  • Step 1 Follow https://next.angular.io/guide/service-worker-getting-started tutorial.
  • Step 2 After add the pwa package, run ng build --prod
  • Step 3 Error occours.

Observed behavior

$ ng build --prod

Date: 2018-05-03T13:29:34.494Z
Hash: 5da3cc601afb0d2ea9a3
Time: 6390ms
chunk {0} runtime.6afe30102d8fe7337431.js (runtime) 1.05 kB [entry] [rendered]
chunk {1} styles.9b2127a46f190bf49065.css (styles) 106 kB [initial] [rendered]
chunk {2} polyfills.7b179b8b06c2bb8cdc21.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} main.aad69072215eb1da4e1b.js (main) 128 bytes [initial] [rendered]

ERROR in Cannot read property 'map' of undefined

Desired behavior

Should build normaly or show me some useful output.

Mention any other details that might be useful (optional)

I've updated from ng5 to ng6 rc last week.

odahcam avatar May 03 '18 13:05 odahcam

I attempted to reproduce this error but was unsuccessful.

Do you have a repo that I can clone to investigate further?

Please try deleting your node_modules dir and reinstalling your dependencies.

Thanks!

Brocco avatar May 03 '18 17:05 Brocco

Sorry, I'm in a closed TFVC, I'll try to delete and install node_modules again.

odahcam avatar May 03 '18 18:05 odahcam

Looks like ng update ... command to update the project to Angular 6 didn't update all modules. I had to upgrade them manually, then the error is gone, but another list of errors was thrown.

odahcam avatar May 04 '18 15:05 odahcam

Finally, I'm stuck here:

$ ng build --prod
Date: 2018-05-04T20:09:24.457Z
Hash: df3dd5afa47779bb72ca
Time: 21116ms
chunk {0} common.333da0f41c6f3801c942.js (common) 5.58 kB  [rendered]
chunk {1} 1.9be22e8fdf445da408da.js () 23 kB  [rendered]
chunk {2} 2.5dae7af7c23a9e13a53d.js () 109 kB  [rendered]
chunk {3} 3.4ae86595565df39e7ca9.js () 10.5 kB  [rendered]
chunk {4} 4.1a94dd5260e0d076ca56.js () 17.2 kB  [rendered]
chunk {5} 5.8001cbcab23b2257022e.js () 32.6 kB  [rendered]
chunk {6} 6.7103d04373020399bc88.js () 171 kB  [rendered]
chunk {7} 7.bff9b7f077865067ee46.js () 11.4 kB  [rendered]
chunk {8} 8.2f08892a0923551b7fe0.js () 35.1 kB  [rendered]
chunk {9} 9.4ae001a2f55b5d32dd4c.js () 206 kB  [rendered]
chunk {10} 10.3537dbcff62cb28a4ac6.js () 813 kB  [rendered]
chunk {11} 11.7b337f1afcc3ae94fb28.js () 6.41 kB  [rendered]
chunk {12} 12.6827c8d663a659805add.js () 25.4 kB  [rendered]
chunk {13} 13.743c2d42436c3aa99e56.js () 44.4 kB  [rendered]
chunk {14} 14.2a5802195fb704f8f595.js () 699 kB  [rendered]
chunk {15} runtime.2247362a82fb33d323c2.js (runtime) 2.2 kB [entry] [rendered]
chunk {16} styles.ac1d7d207728b3fb21d6.css (styles) 107 kB [initial] [rendered]
chunk {17} polyfills.bb2e78e3c72330cda415.js (polyfills) 59.4 kB [initial] [rendered]
chunk {18} main.b8fb797ec174862f08a4.js (main) 788 kB [initial] [rendered]

WARNING in ./node_modules/express/lib/view.js
81:13-25 Critical dependency: the request of a dependency is an expression

ERROR in ./node_modules/cookie-signature/index.js
Module not found: Error: Can't resolve 'crypto' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\cookie-signature'
ERROR in ./node_modules/etag/index.js
Module not found: Error: Can't resolve 'crypto' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\etag'
ERROR in ./node_modules/destroy/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\destroy'
ERROR in ./node_modules/etag/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\etag'
ERROR in ./node_modules/express/lib/view.js
Module not found: Error: Can't resolve 'fs' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/send/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\send'
ERROR in ./node_modules/send/node_modules/mime/mime.js
Module not found: Error: Can't resolve 'fs' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\send\node_modules\mime'ERROR in ./node_modules/express/lib/request.js
Module not found: Error: Can't resolve 'http' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/express/lib/application.js
Module not found: Error: Can't resolve 'http' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/express/lib/response.js
Module not found: Error: Can't resolve 'http' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/express/lib/request.js
Module not found: Error: Can't resolve 'net' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/content-disposition/index.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\content-disposition'
ERROR in ./node_modules/express/lib/application.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/express/lib/response.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/express/lib/view.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\express\lib'
ERROR in ./node_modules/mime-types/index.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\mime-types'
ERROR in ./node_modules/send/index.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\send'
ERROR in ./node_modules/send/node_modules/mime/mime.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\send\node_modules\mime'
ERROR in ./node_modules/serve-static/index.js
Module not found: Error: Can't resolve 'path' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\serve-static'ERROR in ./node_modules/destroy/index.js
Module not found: Error: Can't resolve 'stream' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\destroy'
ERROR in ./node_modules/iconv-lite/lib/streams.jsModule not found: Error: Can't resolve 'stream' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\iconv-lite\lib'
ERROR in ./node_modules/iconv-lite/lib/extend-node.js
Module not found: Error: Can't resolve 'stream' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\iconv-lite\lib'ERROR in ./node_modules/send/index.js
Module not found: Error: Can't resolve 'stream' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\send'
ERROR in ./node_modules/body-parser/lib/read.jsModule not found: Error: Can't resolve 'zlib' in 'C:\TFS-Havan\Desenvolvimento\Development\Source\Inovacao\Havan.Vc\Havan.Vc.Interface.Main\node_modules\body-parser\lib'

Just ng build or ng serve works fine. 😕

odahcam avatar May 04 '18 20:05 odahcam

Fixed by removing the import { Request } from 'express'; in line 4 from:

import { Component, Inject, PLATFORM_ID, Optional, OnInit } from '@angular/core';
import { isPlatformServer } from '@angular/common';
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
import { /* Request, */ Response } from 'express';

@Component({
    selector: 'app-not-found-container',
    templateUrl: './not-found.component.html',
    styleUrls: ['./not-found.component.scss']
})
export class NotFoundComponent implements OnInit {

    constructor(
        @Inject(PLATFORM_ID) private platformId: Object,
        @Optional() @Inject(RESPONSE) private response: Response
    ) {}

    /**
     * Life-cycle hook.
     */
    ngOnInit() {
        if (isPlatformServer(this.platformId)) {
            this.response.sendStatus(404);
        } else {
            console.log('We\'r running on the browser, here\'s the RESPONSE.', this.response);
        }
    }
}

This was not an Angular issue. This just used to work with ng5 compiler.

odahcam avatar May 07 '18 12:05 odahcam

These steps worked for me: 1)Clear package.json with the importat packages for example I have delete my package and insert one by one here is my

{ "name": "test-app", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^6.1.0", "@angular/cdk": "^6.4.2", "@angular/common": "^6.1.0", "@angular/compiler": "^6.1.0", "@angular/core": "^6.1.0", "@angular/flex-layout": "^6.0.0-beta.17", "@angular/forms": "^6.1.0", "@angular/http": "^6.1.0", "@angular/material": "^6.4.2", "@angular/platform-browser": "^6.1.0", "@angular/platform-browser-dynamic": "^6.1.0", "@angular/router": "^6.1.0", "angular2-uuid": "^1.1.1", "chartist": "^0.11.0", "core-js": "^2.5.4", "jquery": "^3.3.1", "rxjs": "^6.0.0", "rxjs-compat": "^6.2.2", "webpack": "^4.16.3", "zone.js": "~0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.7.0", "@angular/cli": "^6.1.2", "@angular/compiler-cli": "^6.1.0", "@angular/language-service": "^6.1.0", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "~4.2.1", "jasmine-core": "~2.99.1", "jasmine-spec-reporter": "~4.2.1", "karma": "~1.7.1", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.0", "karma-jasmine": "~1.1.1", "karma-jasmine-html-reporter": "^0.2.2", "npm-install-webpack-plugin": "^4.0.5", "protractor": "~5.3.0", "ts-node": "~5.0.1", "tslint": "~5.9.1", "typescript": "^2.7.2", "webpack-cli": "^3.1.0", "webpack-dev-server": "^3.1.5" } } delete package_locked.json delete node_modules folder npm install Then ng build --prod was successful.

rodrigowindows avatar Aug 02 '18 00:08 rodrigowindows

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.