_Please make sure you have read the submission guidelines before posting an issue_
Please answer the following questions for yourself before submitting an issue.
YOU MAY DELETE THE PREREQUISITES SECTION.
Should be able to upgrade using yarn upgrade.
it fails with
Cannot convert undefined or null to object
looking through the filed issues, it appears that manually doing
./node_modules/.bin/ng update @nrwl/schematics --from 7.6.0 --to 8 --migrate-only
should do the trick. But it does not.
So I went ahead and tried to debug to pin point where exactly is the issue. it appears at updateBuilders function call at
which further calls updateJsonInTree and readJsonInTree implying that we are not returning any json from the callback. I tried debugging, and verified that both my angular.json and package.json are in correct format. I am adding my angular.json for furthur inspection.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "",
"projects": {
"core": {
"root": "apps/core/",
"sourceRoot": "apps/core/src",
"projectType": "application",
"prefix": "smp",
"schematics": {
"@nrwl/schematics:component": {
"style": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/apps/core",
"index": "apps/core/src/index.html",
"main": "apps/core/src/main.ts",
"polyfills": "apps/core/src/polyfills.ts",
"tsConfig": "apps/core/tsconfig.app.json",
"assets": [
"apps/core/src/favicon.ico",
{
"input": "libs/theme/assets",
"glob": "**/*",
"output": "assets"
}
],
"styles": ["apps/core/src/styles.scss"],
"scripts": [],
"es5BrowserSupport": true
},
"configurations": {
"hmr": {
"fileReplacements": [
{
"replace": "libs/common/src/environments/environment.ts",
"with": "libs/common/src/environments/environment.hmr.ts"
}
]
},
"production": {
"fileReplacements": [
{
"replace": "libs/common/src/environments/environment.ts",
"with": "libs/common/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "core:build"
},
"configurations": {
"hmr": {
"hmr": true,
"browserTarget": "core:build:hmr"
},
"production": {
"browserTarget": "core:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "core:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["apps/core/tsconfig.app.json", "apps/core/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "apps/core/jest.config.js",
"tsConfig": "apps/core/tsconfig.spec.json",
"setupFile": "apps/core/src/test-setup.ts"
}
}
}
},
"core-e2e": {
"root": "apps/core-e2e",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@nrwl/builders:cypress",
"options": {
"cypressConfig": "apps/core-e2e/cypress.json",
"tsConfig": "apps/core-e2e/tsconfig.e2e.json",
"devServerTarget": "core:serve"
},
"configurations": {
"production": {
"devServerTarget": "core:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "apps/core-e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
}
}
}
},
"common": {
"root": "libs/common",
"sourceRoot": "libs/common/src",
"projectType": "library",
"prefix": "smp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/common/tsconfig.lib.json", "libs/common/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "libs/common/jest.config.js",
"tsConfig": "libs/common/tsconfig.spec.json"
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
},
"auth": {
"root": "libs/auth",
"sourceRoot": "libs/auth/src",
"projectType": "library",
"prefix": "smp-auth",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/auth/tsconfig.lib.json", "libs/auth/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "libs/auth/jest.config.js",
"tsConfig": "libs/auth/tsconfig.spec.json",
"setupFile": "libs/auth/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
},
"submissions": {
"root": "libs/submissions",
"sourceRoot": "libs/submissions/src",
"projectType": "library",
"prefix": "smp-submissions",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/submissions/tsconfig.lib.json", "libs/submissions/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "libs/submissions/jest.config.js",
"tsConfig": "libs/submissions/tsconfig.spec.json",
"setupFile": "libs/submissions/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
},
"theme": {
"root": "libs/theme",
"projectType": "library"
},
"ui": {
"root": "libs/ui",
"sourceRoot": "libs/ui/src",
"projectType": "library",
"prefix": "smp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/ui/tsconfig.lib.json", "libs/ui/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "libs/ui/jest.config.js",
"tsConfig": "libs/ui/tsconfig.spec.json",
"setupFile": "libs/ui/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
},
"rest": {
"root": "libs/rest",
"sourceRoot": "libs/rest/src",
"projectType": "library",
"prefix": "smp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/rest/tsconfig.lib.json", "libs/rest/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "libs/rest/jest.config.js",
"tsConfig": "libs/rest/tsconfig.spec.json"
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
},
"pipes": {
"root": "libs/pipes",
"sourceRoot": "libs/pipes/src",
"projectType": "library",
"prefix": "smp",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["libs/pipes/tsconfig.lib.json", "libs/pipes/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/builders:jest",
"options": {
"jestConfig": "libs/pipes/jest.config.js",
"tsConfig": "libs/pipes/tsconfig.spec.json",
"setupFile": "libs/pipes/src/test-setup.ts"
}
}
},
"schematics": {
"@nrwl/schematics:component": {
"styleext": "scss"
}
}
}
},
"cli": {
"warnings": {
"typescriptMismatch": false,
"versionMismatch": false
},
"defaultCollection": "@nrwl/schematics"
},
"schematics": {
"@nrwl/schematics:application": {
"style": "scss"
},
"@nrwl/schematics:library": {
"style": "scss",
"framework": "angular"
}
},
"defaultProject": "core"
}
Any helpers in this regard would be appreciated. thanks.
Thanks for reporting this issue!
It is a bug but to get around it, you can create an architect: {} field for the theme project.
thankyou guys.
I just experienced this same issue today but for a different reason.
My root tsconfig.json did not have a value for compilerOptions.paths because I had previously removed it. I have one app and no libs so far.
I tried adding a lib and got:
Cannot convert undefined or null to object
After debugging the library.js script in node_modules/@nrwl/angular..., I found that the updateTsConfig rule is the source of the bug. It assumes that tsconfig.json already has a value for compilerOptions.paths.
There should be a check there that provides a default value for compilerOptions.paths if one does not exist.
In the meantime, for anyone who experiences this issue, simply add an empty object for compilerOptions.paths to your root tsconfig.json file before running ng g @nrwl/angular:lib ...:
{
"compilerOptions": {
// ...
"paths": {}
}
}
@aaroncadrian Thank you! It worked!
Most helpful comment
I just experienced this same issue today but for a different reason.
My root
tsconfig.jsondid not have a value forcompilerOptions.pathsbecause I had previously removed it. I have one app and no libs so far.I tried adding a lib and got:
After debugging the library.js script in node_modules/@nrwl/angular..., I found that the
updateTsConfigrule is the source of the bug. It assumes thattsconfig.jsonalready has a value forcompilerOptions.paths.https://github.com/nrwl/nx/blob/d9084a08abe8e5885d255df30256dbb303915169/packages/angular/src/schematics/library/library.ts#L390-L396
There should be a check there that provides a default value for
compilerOptions.pathsif one does not exist.In the meantime, for anyone who experiences this issue, simply add an empty object for
compilerOptions.pathsto your roottsconfig.jsonfile before runningng g @nrwl/angular:lib ...: