nx commands are no longer working with non solution tsconfig file

Created on 14 Sep 2020  路  10Comments  路  Source: nrwl/nx

Current Behavior

If you do not have a solution tsconfig file (tsconfig.base.json), nx affected commands fail (and possible others)

Expected Behavior

It should work with non solution config files, i.e. with tsconfig.json file only.

Steps to Reproduce

$ npx create-nx-workspace test-workspace
$ cd test-workspace
$ npx nx affected --target=lint

All works as expected. Rename tsconfig.base.json to tsconfig.json.

$ npx nx affected --target=lint

This will error out.

Failure Logs

Error: ENOENT: no such file or directory, open 'C:\..\.././tsconfig.base.json'
    at Object.openSync (fs.js:448:3)
    at Object.readFileSync (fs.js:350:35)
    at TargetProjectLocator.defaultFileRead [as fileRead] (C:\..\..\node_modules\@nrwl\workspace\src\core\file-utils.js:150:17)
    at new TargetProjectLocator (C:\..\..\node_modules\@nrwl\workspace\src\core\target-project-locator.js:15:73)
    at buildExplicitTypeScriptDependencies (C:\..\..\node_modules\@nrwl\workspace\src\core\project-graph\build-dependencies\explicit-project-dependencies.js:8:34)
    at C:\..\..\node_modules\@nrwl\workspace\src\core\project-graph\project-graph.js:61:41
    at Array.forEach (<anonymous>)
    at buildProjectGraph (C:\..\..\node_modules\@nrwl\workspace\src\core\project-graph\project-graph.js:61:26)
    at Object.createProjectGraph (C:\..\..\node_modules\@nrwl\workspace\src\core\project-graph\project-graph.js:40:30)
    at Object.<anonymous> (C:\..\..\node_modules\@nrwl\workspace\src\command-line\affected.js:23:46) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\..\\..\\temp/./tsconfig.base.json'
}

Environment

 nx : Not Found
  @nrwl/angular : Not Found
  @nrwl/cli : 10.2.0
  @nrwl/cypress : Not Found
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : Not Found
  @nrwl/linter : Not Found
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.2.0
  @nrwl/web : Not Found
  @nrwl/workspace : 10.2.0
  typescript : 3.9.7

Additional Information

I believe the issue was introduced here.

core bug

All 10 comments

I upgraded my angular to 10.1 which removed the tsconfig.base.json file and it was working fine.
After the last update fo nx 10.2.0 it's stopped working with the same above error.

$ nx report

>  NX  Report complete - copy this into the issue template

  nx : Not Found
  @nrwl/angular : 10.2.0
  @nrwl/cli : 10.2.0
  @nrwl/cypress : 10.2.0
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 10.2.0
  @nrwl/linter : 10.2.0
  @nrwl/nest : 10.2.0
  @nrwl/next : Not Found
  @nrwl/node : 10.2.0
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.2.0
  @nrwl/web : Not Found
  @nrwl/workspace : 10.2.0
  typescript : 3.9.7

After modifying target-project-locator.ts to use tsconfig.json file nx commands start working.

Also having the same issue with warnings appearing in PhpStorm too.

@FrozenPandaz we should update the locator to try both tsconfig.base.json and tsconfig.json.

I have a related problem with the rollback of solution style tsconfig files in Angular CLI 10.1:

When I try to add Nx to an existing Angular CLI project via ng add @nrwl/workspace the ng-add schematic fails with the error message:

Cannot read property 'paths' of undefined

That's probably because Nx wants to modify a tsconfig.base.json in the root folder that does not exist anymore in an Angular CLI 10.1 project. I guess there could be more problems related to the missing tsconfig.base.json.

Should I report a new issue for this problem?

What is your suggested workaround? Should I downgrade the project to Angular CLI 10.0 or is there a better option?

Thanks in advance for your help.


Output of ng --version:

Angular CLI: 10.1.1
Node: 12.18.0
OS: darwin x64

Angular: 10.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1001.1
@angular-devkit/build-angular     0.1001.1
@angular-devkit/build-optimizer   0.1001.1
@angular-devkit/build-webpack     0.1001.1
@angular-devkit/core              10.1.1
@angular-devkit/schematics        10.1.1
@ngtools/webpack                  10.1.1
@schematics/angular               10.1.1
@schematics/update                0.1001.1
rxjs                              6.6.3
typescript                        4.0.2
webpack                           4.44.1

Nrwl Nx version: @nrwl/workspace": "^10.2.0

Fixed with #3746. :tada:

Hello, I am facing the same issue with all dependencies up to date.

Cannot read property 'paths' of undefined

  nx : Not Found
  @nrwl/angular : 10.2.1
  @nrwl/cli : 10.2.1
  @nrwl/cypress : 10.2.1
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 10.2.1
  @nrwl/linter : 10.2.1
  @nrwl/nest : 10.2.1
  @nrwl/next : Not Found
  @nrwl/node : 10.2.1
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.2.1
  @nrwl/web : Not Found
  @nrwl/workspace : 10.2.1
  typescript : 4.0.3

@angular/* -> 10.1.3

If I create a symlink from tsconfig.json to tsconfig.base.json it works again.

@vincentpalita Nice workaround with the symlink 馃檪

I have created a new issue for this bug (#3770). This issue has already been fixed on master (btw thanks Nx team for fixing this issue so fast 馃榾). So, the bugfix will be contained in the next release 馃コ

Hello, I have update the @nrwl/workspace module to 10.3.0 and I am still getting the same error:
Cannot read property 'paths' of undefined
@FrozenPandaz can you confirm that the fix hasn't been included in this version? Thank you for your help.

@vincentpalita @FrozenPandaz I have just tested the new Nx release 10.3.0 with the latest Angular CLI version (10.1.4) again.

In my case ng add @nrwl/workspace now completes without any errors (see #3770) 馃コ. But the ng-add schematic doesn't create a root-level tsconfig.base.json file although this file is referenced in the apps/<appname>/tsconfig.app.json file. This leads to several errors, i.e. the app cannot be started.

Also running another Nx schematic (e.g. ng generate @nrwl/angular:library --name=test) exits with Cannot read property 'paths' of undefined.

I will open a new issue for this problem so that I can provide further information.

I have opened a new issue #3874 for the problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichaelWarneke picture MichaelWarneke  路  3Comments

Koslun picture Koslun  路  3Comments

markphip picture markphip  路  3Comments

dereklin picture dereklin  路  3Comments

zpydee picture zpydee  路  3Comments