nx: [bug] [Typescript 3.9] Cannot read property 'paths' of undefined

Current Behavior

Typescript 3.9 add tsconfig.base.json instead ts.config.json

Expected Behavior

Change tsconfig.json to tsconfig.base.json

Steps to Reproduce

  • Run new project
  • Update project to Angular 10.0.1
  • add lib by nx g @nwrl/angular
  • we have an error

Failure Logs

Cannot read property ‘paths’ of undefined

Environment

“dependencies”: { “@nrwl/angular”: “9.4.5”, “@angular/animations”: “^10.0.1”, “@angular/common”: “^10.0.1”, “@angular/compiler”: “^10.0.1”, “@angular/core”: “^10.0.1”, “@angular/forms”: “^10.0.1”, “@angular/platform-browser”: “^10.0.1”, “@angular/platform-browser-dynamic”: “^10.0.1”, “@angular/router”: “^10.0.1”, “core-js”: “^3.6.5”, “rxjs”: “~6.5.5”, “zone.js”: “^0.10.3” }, “devDependencies”: { “@angular/cli”: “10.0.0”, “@nrwl/workspace”: “9.4.5”, “@types/node”: “~14.0.14”, “dotenv”: “8.2.0”, “ts-node”: “~8.10.2”, “tslint”: “~6.1.2”, “eslint”: “7.3.1”, “typescript”: “~3.9.5”, “prettier”: “2.0.5”, “@angular/compiler-cli”: “^10.0.1”, “@angular/language-service”: “^10.0.1”, “@angular-devkit/build-angular”: “0.1000.0”, “codelyzer”: “~5.2.2”, “jest-preset-angular”: “8.2.1”, “@nrwl/jest”: “9.4.5”, “jest”: “26.1.0”, “@types/jest”: “26.0.3”, “ts-jest”: “26.1.1”, “cypress”: “^4.9.0”, “@nrwl/cypress”: “9.4.5” }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 28 (1 by maintainers)

Most upvoted comments

@FrozenPandaz Sorry to reply in this issue after it has been closed. I have found the solution. You were right, i created my workspace like 4 months back, that time the base/root tsconfig file named it as tsconfig.json. And i believe from NX 10, it was renamed to tsconfig.base.json. That was the cause of the problem.

So for anyone having the same issue, rename your root tsconfig.json to tsconfig.base.json and rename all the other tsconfig files which extends from root tsconfig.

Thanks.

just adding the following on the tsconfig.json:
"compilerOptions": { "baseUrl": ".", "rootDir": "." },

worked for me… as a temp solution.

rename tsconfig.json to tsconfig.base.json and update the extends too.

You can temporarily use the schematics by renaming the tsconfig.base.json to tsconfig.json. Not a great solution, but a way to access the schematics in the meantime.

Just make sure you back up the original tsconfig.json.

Hello! FYI, the angular 11 migration schematic rename the tsconfig.base.json to tsconfig.json.

The Solution to fix this issue is here if you still can’t fix this even after updated the version.

  1) Terminate VSCode Completely !
  2) Restart VSCode with new window.
  3) Only Add the project not others. This can be important to smoothly reindex.
  3) CMD+Shift+P and Type 'Restart Angular Language Server' and Select it
  4) (optional)  ' Restart TS Server'
  5)  You may need restart again and do it again.

I fixed it like this way… Hope it was helpful for someone like me.

just adding the following on the tsconfig.json: "compilerOptions": { "baseUrl": ".", "rootDir": "." },

worked for me… as a temp solution.

Exelent temporary solution.

To NX Dev team this is a major issue that holds back from migration to angular 10.

@FrozenPandaz just to let you know, while of course it might be quite a bit of people stammering etc., I can confirm this is indeed an issue. I migrated from nrwl 9 to 11, and tsconfig.json was not changed to tsconfig.base.json. What I did was reference a new nrwl workspace issue from scratch, and that solved it. I.e. saw tsconfig.json is now called tsconfig.base.json. I did the refactor for all extends via my editor of choice(i.e. Webstorm). While I am unfamiliar with the codebase, a perusal into the nx migrate code/logic should show this fault. Someone of less technical expertise would potentially spend more time on something like this. Thank you again, and thank you again for all of your hard work

I am facing the same issue when i try @nrwl/nest:lib schematic. It was working before but after updating “@nrwl/nest”: “10.0.10”,

Edit: it is happening for all the plugins it seems. I tried with react. Had same error.

It seem that the issue is fixed only in the angular schematics as @vsavkin mentioned. However, if angular.json is used as the underlying file, then a similar error appears when trying to generate a @nrwl/node library or a @nrwl/workspace library. I get “Cannot read property ‘types’ of undefined”

This is fixed in Nx 10. Angular schematics now assume the presence of tsconfig.base.json. Could you try version https://www.npmjs.com/package/@nrwl/workspace/v/10.0.0-beta.0?