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

Vue project Error:NX Could not load plugin @nx/vite/plugin #26440

Closed
1 of 4 tasks
cgbin24 opened this issue Jun 7, 2024 · 3 comments
Closed
1 of 4 tasks

Vue project Error:NX Could not load plugin @nx/vite/plugin #26440

cgbin24 opened this issue Jun 7, 2024 · 3 comments
Assignees
Labels
scope: bundlers Issues related to webpack, rollup type: bug

Comments

@cgbin24
Copy link

cgbin24 commented Jun 7, 2024

Current Behavior

Procedure:
1、npx nx g @nx/vue:app main --directory=/apps/
2、npx nx serve main

Error:
NX Could not load plugin @nx/vite/plugin

Expected Behavior

All managed projects can be started normally, regardless of whether 'npx nx serve' is started separately or 'npx nx run-many --target=serve --all' is enabled together

GitHub Repo

https://github.com/cgbin24/myorg-demo

Steps to Reproduce

  1. Use this repository to manage multiple tech stack projects at the same time, such as using 'vue', 'react', and more may be added in the future;
  2. All projects are built with 'vite', everything is normal when you start creating, and the plugins are installed and introduced as normal;
  3. An error is reported when starting the 'vue' project (/apps/main).

Nx Report

➜  myorg-demo git:(main) ✗ npx nx report

 NX   Could not load plugin @nx/vite/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

➜ myorg-demo git:(main) ✗ node -v
v16.18.0

@codemile
Copy link

codemile commented Jun 7, 2024

Did you add the plugin?

nx add @nx/vite

@FrozenPandaz FrozenPandaz added the scope: bundlers Issues related to webpack, rollup label Jun 7, 2024
@cgbin24
Copy link
Author

cgbin24 commented Jun 8, 2024

Did you add the plugin?

nx add @nx/vite

Yes, the '@nx/vite' dependency is already installed in the package in the root directory and is also present in the 'node_modules'

image
image

@Coly010
Copy link
Contributor

Coly010 commented Jun 26, 2024

Because you were unable to run nx report the problem is harder to identify on your end.

You're encountering this issue because you're using mismatched versions of the nx and @nx/ packages.
They are expecting APIs from other packages that just aren't there because of this version mismatch.

When I manually patch the node_modules/@nx/vite/src/plugin/plugin.js file to fix the issue, and then run nx report I get the following:

 NX   Report complete - copy this into the issue template

Node   : 20.12.2
OS     : darwin-arm64
npm    : 10.5.0

nx                 : 19.1.2
@nx/js             : 19.2.0
@nx/jest           : 19.1.2
@nx/linter         : 19.1.2
@nx/eslint         : 19.1.2
@nx/workspace      : 19.1.2
@nx/devkit         : 19.1.2
@nx/eslint-plugin  : 19.1.2
@nx/react          : 19.1.2
@nrwl/tao          : 19.1.2
@nx/vite           : 19.2.0
@nx/vue            : 19.2.0
@nx/web            : 19.2.0
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/jest/plugin
---------------------------------------
The following packages should match the installed version of nx
  - @nx/js@19.2.0
  - @nrwl/js@19.2.0
  - @nx/vite@19.2.0
  - @nrwl/vite@19.2.0
  - @nx/vue@19.2.0
  - @nx/web@19.2.0
  - @nrwl/web@19.2.0

To fix this, run `nx migrate nx@19.2.0`

You can see at the bottom it tells you about the problem in your workspace.

Remember, you MUST keep all your nx package versions aligned.

The easiest way to do this is to use both nx migrate to migrate to newer versions, and nx add when adding new plugnis.

@Coly010 Coly010 closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: bundlers Issues related to webpack, rollup type: bug
Projects
None yet
Development

No branches or pull requests

4 participants