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

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

Open maylukas opened this issue 9 years ago • 34 comments

OS?

node:6.9.4 docker container

Versions.

[email protected] [email protected]

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 [email protected] -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 } }

maylukas avatar Jan 24 '17 15:01 maylukas

Thanks for all the work investigating this issue. @mikejpeters I can confirm this isn't intended and is in fact a bug.

filipesilva avatar Mar 13 '17 18:03 filipesilva

@mikejpeters Which version of CLI are you using? The fallback mechanism has already been changed and fixed https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/models/config.ts#L105 I tried to replicate the issue and seems to be working fine.

Apart from the case where you create empty angular-cli.json or .angular-cli.json file which shouldn't be the case and it doesn't seem to be failing at reading but at parsing JSON file.

I am testing it on @angular/cli: local (v1.0.0-rc.2, branch: angular-master) .

sumitarora avatar Mar 17 '17 15:03 sumitarora

I haven't tested with the latest version, but from reading the source code I don't see any reason the issue would be fixed.

The issue is that the global config is merged with the project config even if they are the exact same path (i.e. project folder = home folder).

mikejpeters avatar Mar 17 '17 16:03 mikejpeters

i just run today to this issue with latest cli and angular-cli.json file in the home. It looks like issue is still there.

ipassynk avatar Apr 21 '17 15:04 ipassynk

I am having this problem when launching it from within Bluemix shell environment only but not in my docker environment:

vcap@af80c6a0-788b-44c6-586d-5423ba47ebde:~$ ng build                                                                                                                     
Cannot read property 'config' of null                                                                                                                                     
TypeError: Cannot read property 'config' of null                                                                                                                          
    at Class.run (/home/vcap/app/node_modules/@angular/cli/tasks/build.js:16:56)                                                                                          
    at Class.run (/home/vcap/app/node_modules/@angular/cli/commands/build.js:143:26)                                                                                      
    at Class.<anonymous> (/home/vcap/app/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)                                                                
    at process._tickCallback (internal/process/next_tick.js:109:7)                                                                                                        

In my Bluemix web shell environment settings are:

vcap@af80c6a0-788b-44c6-586d-5423ba47ebde:~$ ng --version                                                                                                                 
    _                      _                 ____ _     ___                                                                                                               
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|                                                                                                              
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |                                                                                                               
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |                                                                                                               
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|                                                                                                              
               |___/                                                                                                                                                      
@angular/cli: 1.0.0-rc.2                                                                                                                                                  
node: 7.9.0                                                                                                                                                               
os: linux x64                                                                                                                                                             
@angular/cli: 1.0.0-rc.2                                                                                                                                                  
@angular/common: 4.0.3                                                                                                                                                    
@angular/compiler: 4.0.3                                                                                                                                                  
@angular/core: 4.0.3                                                                                                                                                      
@angular/forms: 4.0.3                                                                                                                                                     
@angular/http: 4.0.3                                                                                                                                                      
@angular/platform-browser: 4.0.3                                                                                                                                          
@angular/platform-browser-dynamic: 4.0.3                                                                                                                                  
@angular/router: 4.0.3                                                                                                                                                    
@angular/compiler-cli: 4.0.3                                                                                                                                              
vcap@af80c6a0-788b-44c6-586d-5423ba47ebde:~$ node --version                                                                                                               
v7.9.0                                                                                                                                                                    
vcap@af80c6a0-788b-44c6-586d-5423ba47ebde:~$                                                                                                                              
                                                       

And in my local machine docker settins are:

┌─[127|]─[master]─<default2:~/src/mean-app>
└node_modules/\@angular/cli/bin/ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0-rc.2
node: 7.9.0
os: linux x64
@angular/cli: 1.0.0-rc.2
@angular/common: 4.0.3
@angular/compiler: 4.0.3
@angular/core: 4.0.3
@angular/forms: 4.0.3
@angular/http: 4.0.3
@angular/platform-browser: 4.0.3
@angular/platform-browser-dynamic: 4.0.3
@angular/router: 4.0.3
@angular/compiler-cli: 4.0.3
┌─[0|]─[master]─<default2:~/src/mean-app>
└node --version
v7.9.0
┌─[0|]─[master]─<default2:~/src/mean-app>
└

syscools avatar Apr 25 '17 18:04 syscools

@sumitarora can you have another look at this? There's a couple more reports that seem to indicate some problem with the config merging logic:

  • heroku seems to need explicit redeclare of the HOME var: https://github.com/angular/angular-cli/issues/5808#issuecomment-298309209
  • seems to be happening outside of heroku as well: https://github.com/angular/angular-cli/issues/6227

filipesilva avatar May 10 '17 11:05 filipesilva

Hi, I am changing the schema.js file manually and it works fine. But I want to implement : this._children[name_1] = this._createChildProperty(name_1, value ? value[name_1] : null, forward && forward.children ? forward.children[name_1] : null, propertySchema); in my node modules automatically using ng build through gradle. I am download node v6.9.2 and running npm install and build using gradle task. I get the same error. Please suggest. Is it a version issue or something else?

vinittcs avatar Jul 05 '17 17:07 vinittcs

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

sdsanders avatar Sep 14 '17 21:09 sdsanders

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?

jskrnbindra avatar Sep 21 '17 14:09 jskrnbindra

Thank you SO much @dlimkin Such a stp issue!

Gpzim98 avatar Oct 08 '17 13:10 Gpzim98

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

ysilvestrov avatar Dec 17 '17 23:12 ysilvestrov

@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

codestation avatar Dec 19 '17 16:12 codestation

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.

clydin avatar Sep 25 '18 17:09 clydin

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.