Closed zpydee closed 1 year ago
If this happens both on Nx Console and through the CLI, it doesn't really seem like an issue with Nx Console to me... Can you give any more insight as to why you opened an issue in this repo as opposed to nrwl/nx? Otherwise I will move it there.
because... in vs code, there's a submit a bug link. its your UX :-)
alright that's great that you use that feature :p I'm transferring the bug to the main repo.
π
Hey :) is there any way you could provide a repo that reproduces this? I'll need to see the state of your workspace to understand why this could be happening.
@Coly010
I got the similar issue on a newly generated repo for testing the micro frontend on the latest version.
Getting error: cannot find tsconfig.json
note: there is no tsconfig.json on the root folder on the auto-generated repo
@SandeepThomas I cannot reproduce this error.
Can you post the result of nx report
?
Also, when prompted to choose what workspace to create, you'll be given the following options:
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]
? Choose what to create β¦
Package-based monorepo: Nx makes it fast, but lets you run things your way.
Integrated monorepo: Nx configures your favorite frameworks and lets you focus on shipping features.
Standalone React app: Nx configures Vite and ESLint.
Standalone Angular app: Nx configures Jest, ESLint and Cypress.
What option did you select?
@Coly010 I selected Option 1.
Error Details: ``> NX Generating @nrwl/angular:library
[NX] Angular devkit called writeWorkspace
, this may have created 'workspace.json' or 'angular.json
[NX] Double check workspace configuration before proceeding
Error: ENOENT: no such file or directory, open 'F:\code\package-mono\workspace.json'
at Object.openSync (node:fs:600:3)
at readFileSync (node:fs:468:35)
at FsTree.fsReadFile (F:\code\package-mono\node_modules\nx\src\generators\tree.js:192:44)
at FsTree.read (F:\code\package-mono\node_modules\nx\src\generators\tree.js:22:32)
at convertEventTypeToHandleMultipleConfigNames (F:\code\package-mono\node_modules\nx\src\adapter\ngcli-adapter.js:666:44)
at SafeSubscriber.recorder [as _next] (F:\code\package-mono\node_modules\nx\src\adapter\ngcli-adapter.js:766:23)
at SafeSubscriber.__tryOrUnsub (F:\code\package-mono\node_modules\@angular-devkit\schematics\node_modules\rxjs\internal\Subscriber.js:205:16)
at SafeSubscriber.next (F:\code\package-mono\node_modules\@angular-devkit\schematics\node_modules\rxjs\internal\Subscriber.js:143:22)
at Subscriber._next (F:\code\package-mono\node_modules\@angular-devkit\schematics\node_modules\rxjs\internal\Subscriber.js:89:26)
at Subscriber.next (F:\code\package-mono\node_modules\@angular-devkit\schematics\node_modules\rxjs\internal\Subscriber.js:66:18)
NX Cannot find tsconfig.json
Error: Cannot find tsconfig.json
at readJson (F:\code\package-mono\node_modules\nx\src\generators\utils\json.js:14:15)
at extractTsConfigBase (F:\code\package-mono\node_modules\@nrwl\workspace\src\utils\create-ts-config.js:23:42)
at updateTsConfig (F:\code\package-mono\node_modules\@nrwl\angular\src\generators\library\lib\update-tsconfig.js:47:48)
at F:\code\package-mono\node_modules\@nrwl\angular\src\generators\library\library.js:52:46
at Generator.next (
Selecting option 2, its working fine.
same here im getting wrecked
` w509297@w-702782 Yeti-UI % node node_modules/@nrwl/cli/bin/nx.js generate @nrwl/angular:library --name=graphql --directory=shared/root/security --prefix=yeti --tags=type:util --unitTestRunner=jest --importPath=@yeti/shared-root-security-graphql --strict --linter=eslint --standaloneConfig --compilationMode=partial --viewEncapsulation=Emulated --changeDetection=Default --style=scss --no-interactive --dry-run
NX Generating @nrwl/angular:library
[NX] Angular devkit readJsonWorkspace fell back to Nx workspaces logic
Workspace extension with invalid name (pluginsConfig) found.
Project 'shared-root-security-ui-authenticate' contains extension with invalid name (files).
Project 'shared-root-ui-notification' contains extension with invalid name (files).
Project 'shared-root-security-auth' contains extension with invalid name (files).
Project 'shared-root-ui-components' contains extension with invalid name (files).
Project 'shared-root-environment' contains extension with invalid name (files).
Project 'shared-root-animations' contains extension with invalid name (files).
Project 'shared-root-isomorphic' contains extension with invalid name (files).
Project 'shared-root-ui-feature' contains extension with invalid name (files).
Project 'shared-root-constants' contains extension with invalid name (files).
Project 'shared-root-ui-assets' contains extension with invalid name (files).
Project 'shared-root-ui-common' contains extension with invalid name (files).
Project 'shared-root-ui-styles' contains extension with invalid name (files).
Project 'shared-root-logging' contains extension with invalid name (files).
Project 'shared-root-config' contains extension with invalid name (files).
Project 'shared-root-models' contains extension with invalid name (files).
Project 'shared-root-core' contains extension with invalid name (files).
Project 'ui-dashboard-e2e' contains extension with invalid name (files).
Project 'ui-navigation' contains extension with invalid name (files).
Project 'ui-cards-e2e' contains extension with invalid name (files).
Project 'ui-dashboard' contains extension with invalid name (files).
Project 'ui-cards' contains extension with invalid name (files).
Project 'ui-auth' contains extension with invalid name (files).
Project 'ui-main' contains extension with invalid name (files).
[NX] Angular devkit readJsonWorkspace fell back to Nx workspaces logic
Workspace extension with invalid name (pluginsConfig) found.
Project 'shared-root-security-ui-authenticate' contains extension with invalid name (files).
Project 'shared-root-ui-notification' contains extension with invalid name (files).
Project 'shared-root-security-auth' contains extension with invalid name (files).
Project 'shared-root-ui-components' contains extension with invalid name (files).
Project 'shared-root-environment' contains extension with invalid name (files).
Project 'shared-root-animations' contains extension with invalid name (files).
Project 'shared-root-isomorphic' contains extension with invalid name (files).
Project 'shared-root-ui-feature' contains extension with invalid name (files).
Project 'shared-root-constants' contains extension with invalid name (files).
Project 'shared-root-ui-assets' contains extension with invalid name (files).
Project 'shared-root-ui-common' contains extension with invalid name (files).
Project 'shared-root-ui-styles' contains extension with invalid name (files).
Project 'shared-root-logging' contains extension with invalid name (files).
Project 'shared-root-config' contains extension with invalid name (files).
Project 'shared-root-models' contains extension with invalid name (files).
Project 'shared-root-core' contains extension with invalid name (files).
Project 'ui-dashboard-e2e' contains extension with invalid name (files).
Project 'ui-navigation' contains extension with invalid name (files).
Project 'ui-cards-e2e' contains extension with invalid name (files).
Project 'ui-dashboard' contains extension with invalid name (files).
Project 'ui-cards' contains extension with invalid name (files).
Project 'ui-auth' contains extension with invalid name (files).
Project 'ui-main' contains extension with invalid name (files).
[NX] Angular devkit called writeWorkspace
, this may have had unintended consequences in workspace.json
[NX] Double check workspace.json before proceeding
[NX] Angular devkit readJsonWorkspace fell back to Nx workspaces logic
Workspace extension with invalid name (pluginsConfig) found.
Project 'shared-root-security-ui-authenticate' contains extension with invalid name (files).
Project 'shared-root-ui-notification' contains extension with invalid name (files).
Project 'shared-root-security-auth' contains extension with invalid name (files).
Project 'shared-root-ui-components' contains extension with invalid name (files).
Project 'shared-root-environment' contains extension with invalid name (files).
Project 'shared-root-animations' contains extension with invalid name (files).
Project 'shared-root-isomorphic' contains extension with invalid name (files).
Project 'shared-root-ui-feature' contains extension with invalid name (files).
Project 'shared-root-constants' contains extension with invalid name (files).
Project 'shared-root-ui-assets' contains extension with invalid name (files).
Project 'shared-root-ui-common' contains extension with invalid name (files).
Project 'shared-root-ui-styles' contains extension with invalid name (files).
Project 'shared-root-logging' contains extension with invalid name (files).
Project 'shared-root-config' contains extension with invalid name (files).
Project 'shared-root-models' contains extension with invalid name (files).
Project 'shared-root-core' contains extension with invalid name (files).
Project 'ui-dashboard-e2e' contains extension with invalid name (files).
Project 'ui-navigation' contains extension with invalid name (files).
Project 'ui-cards-e2e' contains extension with invalid name (files).
Project 'ui-dashboard' contains extension with invalid name (files).
Project 'ui-cards' contains extension with invalid name (files).
Project 'ui-auth' contains extension with invalid name (files).
Project 'ui-main' contains extension with invalid name (files).
SchematicsException [Error]: Project "shared-root-security-graphql" does not exist.
at /Users/w509297/PR/150305/Yeti-UI/node_modules/@schematics/angular/component/index.js:32:19
at processTicksAndRejections (node:internal/process/task_queues:96:5)
NX Project "shared-root-security-graphql" does not exist.
Pass --verbose to see the stacktrace. `
If this is in the package-based
repo selection, we are investigating it internally and working on the correct solution.
While we continue to work on this, the workaround would be to do the following
tsconfig.base.json
at the root of your workspace with the following contents:{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2017", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {}
},
"exclude": ["node_modules", "tmp"]
}
aplogies, i've been away from github for a couple weeks. my tsconfig.base.json has these options with the only difference being the empty path object in yours.
implementing identically unfortunately yields no solution.
@Coly010 would it be helpful if we had a quick online session to look at my repo together? I unfortunately cannot give access.
@Coly010 I've created a demo repo for you to look at...
It looks like this issue has been resolved in latest Nx.
If you are unable to migrate to latest Nx because you're still on Angular 14 and don't want to migrate to Angular 15, we'll soon be releasing support for Angular 14 + Angular 15 in Nx 15.x.
That way, you'll be able to migrate to the latest version of Nx without having to migrate Angular
My sincere apologies - when I replicated my repo to demo I made the mistake of using an older branch that was running ng 14.
However, I've now migrated to nx 15.6.3 in my actual repo and I'm still experiencing the same problem.
here's my nx report
Node : 16.14.2
OS : darwin arm64
npm : 8.5.0
nx : 15.6.3
@nrwl/angular : 15.6.3
@nrwl/cypress : 15.6.3
@nrwl/detox : Not Found
@nrwl/devkit : 15.6.3
@nrwl/esbuild : Not Found
@nrwl/eslint-plugin-nx : 15.6.3
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 15.6.3
@nrwl/js : 15.6.3
@nrwl/linter : 15.6.3
@nrwl/nest : 15.6.3
@nrwl/next : Not Found
@nrwl/node : 15.6.3
@nrwl/nx-cloud : 15.0.2
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/rollup : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : Not Found
@nrwl/web : Not Found
@nrwl/webpack : 15.6.3
@nrwl/workspace : 15.6.3
@nrwl/vite : Not Found
typescript : 4.8.4
---------------------------------------
Local workspace plugins:
---------------------------------------
Community plugins:
@ngrx/component-store: 15.0.0
@ngrx/effects: 15.0.0
@ngrx/entity: 15.0.0
@ngrx/router-store: 15.0.0
@ngrx/store: 15.0.0
@ngrx/schematics: 15.0.0
@ngrx/store-devtools: 15.0.0
eslint-plugin-ngrx: 2.1.4
@Coly010 i think we're in the same time zone. Would you be interested in a quick slack huddle? If not, I can create another empty repo with my "actual" environment and repost?
Thanks in advance for your assistance...
@zpydee I think creating a new repo that replicates your environment would be better, it'll be easier for others to pick up the issue if I can't etc.
Ok, this repo π is now running 15.6.3
with the issue I'm experiencing still occurring
hey @zpydee!
Thanks for providing a repo where we can reproduce it.
The issue is happening because of an old version of @angular-devkit/schematics
being hoisted at the root of your node_modules
:
npm ls @angular-devkit/schematics
βββ¬ @angular/cli@15.1.2
β βββ @angular-devkit/schematics@15.1.2
β βββ¬ @schematics/angular@15.1.2
β βββ @angular-devkit/schematics@15.1.2 deduped
βββ¬ @angular/fire@7.5.0
β βββ @angular-devkit/schematics@13.3.9 invalid: "14.2.9" from node_modules/@ngrx/schematics
β βββ¬ @schematics/angular@15.0.1
β βββ @angular-devkit/schematics@15.0.1
βββ¬ @angular/pwa@15.0.1
β βββ @angular-devkit/schematics@15.0.1
βββ¬ @nestjs/schematics@9.0.3
β βββ @angular-devkit/schematics@14.2.1
βββ¬ @ngrx/schematics@15.0.0
β βββ @angular-devkit/schematics@13.3.9 deduped invalid: "14.2.9" from node_modules/@ngrx/schematics
βββ¬ @nrwl/angular@15.6.3
β βββ @angular-devkit/schematics@15.1.2
β βββ¬ @schematics/angular@15.1.2
β βββ @angular-devkit/schematics@15.1.2 deduped
βββ¬ eslint-plugin-ngrx@2.1.4
βββ @angular-devkit/schematics@13.3.9 deduped invalid: "14.2.9" from node_modules/@ngrx/schematics
npm ERR! code ELSPROBLEMS
npm ERR! invalid: @angular-devkit/schematics@13.3.9 /Users/leosvel/code/issues/13544-cannot-generate-lib/node_modules/@angular-devkit/schematics
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/leosvel/.npm/_logs/2023-01-31T08_41_52_679Z-debug-0.log
If you set "@angular-devkit/schematics": "15.1.3"
in your package.json,
the issue goes away. Nuking the node_modules
and deleting your package-lock.json
should also do the trick, but I recommend doing the former, which is more deterministic.
You have probably ended up in this state because of how npm
resolves dependencies through time. The lock file is not updated with newer versions of @angular-devkit/schematics
that those packages can depend on. That's why it should work correctly if you delete the lock file and recreate it by installing it again.
On a separate note, the eslint-plugin-ngrx
package is deprecated and you should use the @ngrx/eslint-plugin
package instead. That should remove one package that depends on an old version of @angular-devkit/schematics
.
Thanks a ton for your speedy response. I'll take a look and let you know if I have any further issues.
If I may ask another quick question....
I notice when I created a fresh nx workspace that angular.json
as not present anymore. Should I be doing anything on that front in my repo to keep it more aligned with the way fresh workspaces are created?
It'll work fine either way, though you can remove it if you want. As you noticed, we don't generate it in new workspaces, because it's no longer required. A migration will remove angular.json
files with a format version "2" in an upcoming version.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
I have gone through an upgrade of nx from v13 to @latest over a couple of days, and I am no longer able to generate angular libs which has kind of ground me to a halt
Expected Behavior
generate @nrwl/angular:lib should work (Ihave tried on console and through nx console, with the same failure result
Steps to Reproduce
i wish i could, but i obviously did something wrong during the upgrade process,
Failure Logs / Images / Videos
I believe the wanrings in the beginning part of the log are appratently unimportant, but as you'll see the script does error.
the error message is surprising since the lib mentioned is the one i'm trying to generate.
Environment