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

nx g plugin creates invalid dependencies in package.json #19386

Closed
1 of 4 tasks
daiscog opened this issue Sep 29, 2023 · 3 comments · Fixed by #19429
Closed
1 of 4 tasks

nx g plugin creates invalid dependencies in package.json #19386

daiscog opened this issue Sep 29, 2023 · 3 comments · Fixed by #19429

Comments

@daiscog
Copy link
Contributor

daiscog commented Sep 29, 2023

Current Behavior

After running nx g plugin, a clean npm install fails with peer dependency errors.

Expected Behavior

nx g plugin does not add incompatible deps to package.json

GitHub Repo

No response

Steps to Reproduce

npx create-nx-workspace@latest  # 16.9.1 at time of writing
  # select options for Angular, integrated monorepo

cd new-workspace    # whatever you called it above

npm i @nx/plugin    # again 16.9.1 at time of writing
nx g plugin
  # follow prompts

rm -rf node_modules package-lock.json
npm install

The final npm install fails with:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: nx@16.9.1
npm ERR! Found: @swc-node/register@1.4.2
npm ERR! node_modules/@swc-node/register
npm ERR!   dev @swc-node/register@"~1.4.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @swc-node/register@"^1.6.7" from nx@16.9.1
npm ERR! node_modules/nx
npm ERR!   dev nx@"16.9.1" from the root project
npm ERR!   peer nx@">= 15 <= 17" from @nx/devkit@16.9.1
npm ERR!   node_modules/@nx/devkit
npm ERR!     @nx/devkit@"16.9.1" from the root project
npm ERR!     11 more (@nx/angular, @nx/cypress, @nx/eslint-plugin, @nx/jest, ...)
npm ERR!   2 more (@nx/workspace, @nrwl/tao)
npm ERR! 
npm ERR! Conflicting peer dependency: @swc-node/register@1.6.8
npm ERR! node_modules/@swc-node/register
npm ERR!   peerOptional @swc-node/register@"^1.6.7" from nx@16.9.1
npm ERR!   node_modules/nx
npm ERR!     dev nx@"16.9.1" from the root project
npm ERR!     peer nx@">= 15 <= 17" from @nx/devkit@16.9.1
npm ERR!     node_modules/@nx/devkit
npm ERR!       @nx/devkit@"16.9.1" from the root project
npm ERR!       11 more (@nx/angular, @nx/cypress, @nx/eslint-plugin, @nx/jest, ...)
npm ERR!     2 more (@nx/workspace, @nrwl/tao)

Obviously this can be fixed by manually setting the version of @swc-node/register in package.json to 1.6.7, but ideally the plugin generator shouldn't create incompatible deps.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.20.0
   OS     : darwin-x64
   npm    : 8.19.4
   
   nx                 : 16.9.1
   @nx/js             : 16.9.1
   @nx/jest           : 16.9.1
   @nx/linter         : 16.9.1
   @nx/workspace      : 16.9.1
   @nx/angular        : 16.9.1
   @nx/cypress        : 16.9.1
   @nx/devkit         : 16.9.1
   @nx/eslint-plugin  : 16.9.1
   @nx/plugin         : 16.9.1
   @nrwl/tao          : 16.9.1
   @nx/web            : 16.9.1
   @nx/webpack        : 16.9.1
   typescript         : 5.1.6

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@phaze-phusion
Copy link

Can confirm it happens on Linux too (Ubuntu 22.04):

 >  NX   Report complete

   Node   : 18.17.0
   OS     : linux-x64
   npm    : 9.6.7

Using PNPM instead of NPM passes with a clear warning:

 WARN  Issues with peer dependencies found
.
└─┬ @nx/cypress 16.9.1
  └─┬ @nx/js 16.9.1
    └─┬ @nx/workspace 16.9.1
      └─┬ nx 16.9.1
        ├── ✕ unmet peer @swc-node/register@^1.6.7: found 1.4.2
        └─┬ @nrwl/tao 16.9.1
          └─┬ nx 16.9.1
            └── ✕ unmet peer @swc-node/register@^1.6.7: found 1.4.2

Done in 30.8s

Output of nx report:

 >  NX   Report complete - copy this into the issue template

   Node   : 18.17.0
   OS     : linux-x64
   pnpm   : 8.8.0
   
   nx (global)        : 16.9.1
   nx                 : 16.9.1
   @nx/js             : 16.9.1
   @nx/jest           : 16.9.1
   @nx/linter         : 16.9.1
   @nx/workspace      : 16.9.1
   @nx/angular        : 16.9.1
   @nx/cypress        : 16.9.1
   @nx/devkit         : 16.9.1
   @nx/eslint-plugin  : 16.9.1
   @nx/plugin         : 16.9.1
   @nrwl/tao          : 16.9.1
   @nx/web            : 16.9.1
   nx-cloud           : 16.4.0
   typescript         : 5.1.6

Definitely a bug

@daiscog
Copy link
Contributor Author

daiscog commented Oct 2, 2023

I would argue that these swc dependencies shouldn't be added to the project's package.json at all because no local code uses them directly. Instead, they should come in as dependencies/peerDependencies of the @nx/plugin package.

Copy link

github-actions bot commented Nov 3, 2023

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 Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants