question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR in Cannot read property 'map' of undefined

See original GitHub issue

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

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
odahcamcommented, May 7, 2018

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.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error : Cannot read property 'map' of undefined - Stack Overflow
The error Cannot read property 'map' of undefined' is thrown when the map function in the CommentList component is executed.
Read more >
Fix the "Cannot read property 'map' of undefined" Error in React
The variable you are trying to map over is undefined . It will probably eventually be an array, but due to the asynchronous...
Read more >
How to Prevent the TypeError: Cannot Read Property Map of ...
As a result, the TypeError Cannot read property 'map' of undefined is very common and one of the first errors that developers will...
Read more >
Cannot read properties of undefined (reading 'map') in React
The "TypeError: Cannot read properties of undefined (reading 'map')" occurs when we call the map() method on an undefined value, most often when...
Read more >
React - Cannot read property 'map' of undefined - debuggr.io
React evaluate our return statement, when it hits the items.map(...) line its actually running undefined.map(...) which is obviously an error in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found