Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local plugins not detected when using workspace.json #12451

Closed
robdonn opened this issue Oct 6, 2022 · 3 comments
Closed

Local plugins not detected when using workspace.json #12451

robdonn opened this issue Oct 6, 2022 · 3 comments

Comments

@robdonn
Copy link

robdonn commented Oct 6, 2022

Current Behavior

When using the latest version of NX (14.8.3 as of this issue creation) commands fail as NX cannot resolve the location of a local nx-plugin if a workspace.json file is used in the project.

Expected Behavior

NX should be able to resolve the location of the local nx-plugin.

Steps to Reproduce

Example PR

  • Create an NX project
  • Generate an app (e.g. React app)
  • Generate a local nx-plugin (@nrwl/nx-plugin)
  • In nx.json add the local nx-plugin to the plugins field.
  • Create a workspace.json at the root of the project
    • { "version": 2, "projects: [] }
  • nx run <appName>:build

Failure Logs

Log from example pull request in nx-examples repo.

 >  NX   Cannot find module '@nx-example/broken-plugin'

   Require stack:
   - /Users/robert.donnelly/robdonn/nx-examples/node_modules/nx/src/utils/nx-plugin.js
   - /Users/robert.donnelly/robdonn/nx-examples/node_modules/nx/src/config/workspaces.js
   - /Users/robert.donnelly/robdonn/nx-examples/node_modules/nx/src/config/configuration.js
   - /Users/robert.donnelly/robdonn/nx-examples/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js
   - /Users/robert.donnelly/robdonn/nx-examples/node_modules/nx/src/daemon/server/server.js
   - /Users/robert.donnelly/robdonn/nx-examples/node_modules/nx/src/daemon/server/start.js
   
   Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
   If the error persists, please run "nx reset".

Environment

Note: I had to remove the local plugin reference from nx.json to get nx report command to work

   Node : 16.10.0
   OS   : darwin arm64
   yarn : 1.22.11
   
   nx : 14.8.3
   @nrwl/angular : 14.8.3
   @nrwl/cypress : 14.8.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.8.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.3
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.8.3
   @nrwl/js : 14.8.3
   @nrwl/linter : 14.8.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 14.6.1
   @nrwl/nx-plugin : 14.8.3
   @nrwl/react : 14.8.3
   @nrwl/react-native : Not Found
   @nrwl/rollup : 14.8.3
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.8.3
   @nrwl/web : 14.8.3
   @nrwl/webpack : 14.8.3
   @nrwl/workspace : 14.8.3
   typescript : 4.7.2
   ---------------------------------------
   Local workspace plugins:
         @nx-example/broken-plugin
   ---------------------------------------
   Community plugins:
         @ngrx/component-store: 14.0.2
         @ngrx/effects: 14.0.2
         @ngrx/entity: 14.0.2
         @ngrx/router-store: 14.0.2
         @ngrx/store: 14.0.2
         @ngrx/store-devtools: 14.0.2
@lewsmith
Copy link
Contributor

lewsmith commented Oct 7, 2022

I'm also seeing an issue with 14.8.3 and local plugins. Slightly different to above (initially).

I'm using a plugin to extend the dep graph for go projects. It was working perfectly with the previous version but now I'm getting the following error when trying to run nx graph:

> NX   unable to find tsconfig.base.json or tsconfig.json

function readTsConfigPaths(root: string = workspaceRoot) {
if (!tsconfigPaths) {
const tsconfigPath: string | null = ['tsconfig.base.json', 'tsconfig.json']
.map((x) => path.join(root, x))
.filter((x) => existsSync(x))[0];
if (!tsconfigPath) {
throw new Error('unable to find tsconfig.base.json or tsconfig.json');
}
const { compilerOptions } = readJsonFile(tsconfigPath);
tsconfigPaths = compilerOptions?.paths;
}
return tsconfigPaths ?? {};
}

The latest version appears to be searching for tsconfig files in every project. However, I have go projects that do not have a tsconfig in it's project root. I don't really want to add one either.

If I do add a tsonfig.json to all my go projects I go from getting that error to the same as the OP:

>  NX   Cannot find module '@libs/nx-go'

   Require stack:
   - /home/lewsmith/Workspace/Personal/project-x/node_modules/nx/src/utils/nx-plugin.js
   - /home/lewsmith/Workspace/Personal/project-x/node_modules/nx/src/config/workspaces.js
   - /home/lewsmith/Workspace/Personal/project-x/node_modules/nx/src/config/configuration.js
   - /home/lewsmith/Workspace/Personal/project-x/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js
   - /home/lewsmith/Workspace/Personal/project-x/node_modules/nx/src/daemon/server/server.js
   - /home/lewsmith/Workspace/Personal/project-x/node_modules/nx/src/daemon/server/start.js

For now I will roll back to the previous version.

Environment

   Node : 16.13.1
   OS   : linux x64
   yarn : 1.22.10
   
   nx : 14.8.3
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.8.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.8.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.3
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 14.8.3
   @nrwl/js : 14.8.3
   @nrwl/linter : 14.8.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : 14.8.3
   @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 : Not Found
   @nrwl/workspace : 14.8.3
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
         @libs/nx-go
   ---------------------------------------
   Community plugins:
         @jscutlery/semver: 2.27.0

@robdonn
Copy link
Author

robdonn commented Oct 7, 2022

Closing as my issue appears to be a duplicate of #12340 which was fixed by #12406

I replicated the change locally and it did fix the problem. Just waiting for it to make it into a release now.

@robdonn robdonn closed this as completed Oct 7, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants