Skip to content

Production build fails with message "Cannot read property 'input' of null" #4207

Closed

Description

@maylukas

OS?

node:6.9.4 docker container

Versions.

node@v6.9.4
angular-cli@1.0.0-beta.26

Repro steps.

After an upgrade to 1.0.0-beta.26 from 1.0.0-beta.24 the app fails to build.
Build always starts with a clean docker container in which the following steps are run:
FROM node:6.9.4
WORKDIR /root/
RUN npm install angular-cli@1.0.0-beta.26 -g

COPY package.json ./package.json
RUN npm install

COPY src ./src/
COPY e2e ./e2e/
COPY angular-cli.json ./angular-cli.json
COPY protractor.conf.js ./protractor.conf.js
COPY karma.conf.js ./karma.conf.js
COPY tslint.json ./tslint.json

RUN ng build --prod

Prod build works when running on the development machine with Windows 7

The log given by the failure.

Cannot read property 'input' of null
TypeError: Cannot read property 'input' of null
at ObjectSchemaTreeNode._set (/root/node_modules/@ngtools/json-schema/src/sc
hema-tree.js:347:132)
at new ObjectSchemaTreeNode (/root/node_modules/@ngtools/json-schema/src/sch
ema-tree.js:331:14)
at OneOfSchemaTreeNode.NonLeafSchemaTreeNode._createChildProperty (/root/nod
e_modules/@ngtools/json-schema/src/schema-tree.js:244:24)
at /root/node_modules/@ngtools/json-schema/src/schema-tree.js:260:26
at Array.map (native)
at new OneOfSchemaTreeNode (/root/node_modules/@ngtools/json-schema/src/sche
ma-tree.js:259:48)
at ArraySchemaTreeNode.NonLeafSchemaTreeNode._createChildProperty (/root/nod
e_modules/@ngtools/json-schema/src/schema-tree.js:244:24)
at ArraySchemaTreeNode._set (/root/node_modules/@ngtools/json-schema/src/sch
ema-tree.js:434:39)
at new ArraySchemaTreeNode (/root/node_modules/@ngtools/json-schema/src/sche
ma-tree.js:414:14)
at ObjectSchemaTreeNode.NonLeafSchemaTreeNode._createChildProperty (/root/no
de_modules/@ngtools/json-schema/src/schema-tree.js:244:24)
at ObjectSchemaTreeNode._set (/root/node_modules/@ngtools/json-schema/src/sc
hema-tree.js:347:47)
at new ObjectSchemaTreeNode (/root/node_modules/@ngtools/json-schema/src/sch
ema-tree.js:331:14)
at ArraySchemaTreeNode.NonLeafSchemaTreeNode._createChildProperty (/root/nod
e_modules/@ngtools/json-schema/src/schema-tree.js:244:24)
at ArraySchemaTreeNode._set (/root/node_modules/@ngtools/json-schema/src/sch
ema-tree.js:434:39)
at new ArraySchemaTreeNode (/root/node_modules/@ngtools/json-schema/src/sche
ma-tree.js:414:14)
at RootSchemaTreeNode.NonLeafSchemaTreeNode._createChildProperty (/root/node
_modules/@ngtools/json-schema/src/schema-tree.js:244:24)
at RootSchemaTreeNode.ObjectSchemaTreeNode._set (/root/node_modules/@ngtools
/json-schema/src/schema-tree.js:347:47)
at RootSchemaTreeNode.ObjectSchemaTreeNode [as constructor] (/root/node_modu
les/@ngtools/json-schema/src/schema-tree.js:331:14)
at new RootSchemaTreeNode (/root/node_modules/@ngtools/json-schema/src/schem
a-tree.js:478:16)
at GeneratedSchemaClass.SchemaClassBase (/root/node_modules/@ngtools/json-sc
hema/src/schema-class-factory.js:66:29)
at new GeneratedSchemaClass (/root/node_modules/@ngtools/json-schema/src/sch
ema-class-factory.js:165:20)
at new CliConfig (/root/node_modules/angular-cli/models/config/config.js:24:
24)
at Function.CliConfig.fromConfigPath (/root/node_modules/angular-cli/models/
config/config.js:99:16)
at Function.CliConfig.fromProject (/root/node_modules/angular-cli/models/con
fig.js:63:44)
at Class.run (/root/node_modules/angular-cli/tasks/build-webpack.js:14:73)
at Class.buildRun (/root/node_modules/angular-cli/commands/build.run.js:39:2
2)
at Class.run (/root/node_modules/angular-cli/commands/build.js:38:47)
at Class. (/root/node_modules/angular-cli/ember-cli/lib/models/co
mmand.js:147:17)
at process._tickCallback (internal/process/next_tick.js:103:7)
The command '/bin/sh -c ng build --prod' returned a non-zero code: 1

Mention any other details that might be useful.

angular-cli.json

{
"project": {
"version": "1.0.0-alpha.2",
"name": "core-ui"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"genDir": "gen",
"assets": ["assets"],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"scss/style.scss"
],
"scripts": [
"../node_modules/pace-js/pace.min.js",
"../node_modules/chart.js/dist/Chart.bundle.min.js",
"../node_modules/chart.js/dist/Chart.min.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"prefixInterfaces": false
}
}

Activity

  1. maylukas commented on Jan 24, 2017

    @maylukas
    Author

    I don't know the cause of the issue as i did not invest enough time to understand the parsing of the configuration but if I change Line 347 in @ngtools/json-schema/src/schema-tree.js from
    this._children[name_1] = this._createChildProperty(name_1, value ? value[name_1] : null, forward ? forward.children[name_1] : null, propertySchema);
    to this:
    this._children[name_1] = this._createChildProperty(name_1, value ? value[name_1] : null, forward && forward.children ? forward.children[name_1] : null, propertySchema);

    it works again

  2. filipesilva commented on Jan 24, 2017

    @filipesilva
    Contributor

    Can you show me your angular-cli.json? Maybe you have a property there that's not supported anymore or something.

  3. maylukas commented on Jan 25, 2017

    @maylukas
    Author

    I actually provided it in the issue description under "Mention any other details that might be useful.".

  4. hoatle commented on Jan 26, 2017

    @hoatle

    I'm having the same exact problem.

  5. hoatle commented on Jan 29, 2017

    @hoatle

    I guess this is the root cause (related to Docker, not sure about other cases).

    When I have angular app under $HOME path, I got the same exact problem.

    When I move the angular app out of $HOME path, it works as expected, no error.

  6. hoatle commented on Jan 29, 2017

    @hoatle

    @maylukas this configuration should work with your project:

    FROM node:6.9.4
    
    RUN mkdir -p /opt/app
    WORKDIR /opt/app
    RUN npm install angular-cli@1.0.0-beta.26 -g
    
    COPY package.json ./package.json
    RUN npm install
    
    COPY src ./src/
    COPY e2e ./e2e/
    COPY angular-cli.json ./angular-cli.json
    COPY protractor.conf.js ./protractor.conf.js
    COPY karma.conf.js ./karma.conf.js
    COPY tslint.json ./tslint.json
    
    RUN ng build --prod
    
  7. alexweber commented on Feb 1, 2017

    @alexweber

    @hoatle Thanks for taking the time to share this, can't say how happy I am to have this working finally! :)

  8. alexweber commented on Feb 2, 2017

    @alexweber

    @giertych97 That's unrelated to this particular issue. See here for a fix for the new release breaking builds: #4326 (comment)

  9. dustintheweb commented on Feb 2, 2017

    @dustintheweb

    @filipesilva I have had the same issue in my production builds to Heroku since Beta 25 (Beta 24 & earlier worked great, however I just updated to Beta 28 & can confirm the issue still exists).

    2017-02-02T13:23:29.383781+00:00 app[web.1]: TypeError: Cannot read property 'input' of null
    2017-02-02T13:23:29.383783+00:00 app[web.1]:     at new ObjectSchemaTreeNode (/app/node_modules/@ngtools/json-schema/src/schema-tree.js:331:14)
    

    I believe it may have something to do with the JSON Schema feature added in Beta 25:

    @ngtools/json-schema: Introduce a separate package for JSON schema. (#3927) (74f7cdd)
    

    This does not happen when I kick off a build in my local environment npm start - all things are working as expected on localhost:4300. It is only when I deploy & Heroku kicks off the npm start that it will fail on the ng build (it breaks before it is able to create a /dist folder)

    This type of error message is similar to the ones seen when an npm package is missing a Types declaration file - unfortunately, one does not exist for the JSON Schema package. Maybe this is related to that? Another hunch is that it may be related to Linux.

    I made a comment on this in another thread a while back but didn't follow up until just now - here's a link for additional context

    Hopefully this provides some additional insight to the bug

  10. dlimkin commented on Feb 2, 2017

    @dlimkin

    Maybe this will help. I accidentally called ng init in Нome directory, after call the ng in any other directory caused the error (even when call ng --version). After deleting ng files from the home directory. ng runs without errors

  11. juanmcampos commented on Feb 2, 2017

    @juanmcampos

    @dustintheweb did you find any solution?

  12. Mattee commented on Feb 3, 2017

    @Mattee

    @dlimkin Thank you, it solved my problem! It seems like I had some old Angular files in the root of my home directory causing all Angular projects in there with later Angular-cli versions to fail. So by deleting all files and folders that doesn't belong to the home directory, it solves the problems and the errors disappears.

  13. robertorosas commented on Feb 3, 2017

    @robertorosas

    @dlimkin solution works. Removing all the ng files from the home directory solved it. Thanks.

  14. 29 remaining items

  15. sdsanders commented on Sep 14, 2017

    @sdsanders

    Still running into this (on dokku) with the latest version of the cli.

  16. jskrnbindra commented on Sep 21, 2017

    @jskrnbindra

    The issue still exists on latest @angular/cli
    Works on my windows machine but throws this error:

    TypeError: Cannot read property 'glob' of null

    on centos in aws.

    All was good until today morning when the error just popped up while running:
    ng build && node server.js

    on CentOS.

    Is there a fix?

  17. Gpzim98 commented on Oct 8, 2017

    @Gpzim98

    Thank you SO much @dlimkin
    Such a stp issue!

  18. ysilvestrov commented on Dec 17, 2017

    @ysilvestrov

    The same issue for me with dokku today.
    Updated @angular/cli to 1.6.1 with no help.

    Could we expect a fix?
    The non-working repo, if needed, is https://github.com/ysilvestrov/ontap-tv

  19. codestation commented on Dec 19, 2017

    @codestation

    @ysilvestrov redefine HOME to any other directory before building, for example i have this in my package.json

        "heroku-postbuild": "HOME=/tmp/build ng build --prod --aot --no-progress"
    

    The bug appears when $HOME contains a .angular-cli.json and since dokku puts the project in $HOME then the bug triggers

  20. assigned and unassigned on Feb 6, 2018
  21. clydin commented on Sep 25, 2018

    @clydin
    Member

    Closing as version 1.0.0-beta.26 is a prerelease version and no longer supported. If the problem persists within the latest stable version (currently 6.2.3), please open a new issue detailing the problem.

  22. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  23. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions