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 lib creates invalid dependencies in package.json #23688

Closed
1 of 4 tasks
Den-dp opened this issue May 20, 2024 · 2 comments · Fixed by #24034
Closed
1 of 4 tasks

nx g lib creates invalid dependencies in package.json #23688

Den-dp opened this issue May 20, 2024 · 2 comments · Fixed by #24034
Assignees
Labels

Comments

@Den-dp
Copy link
Contributor

Den-dp commented May 20, 2024

Current Behavior

After running nx g lib foo --unitTestRunner jest --bundler tsc, a clean npm install fails with peer dependency errors.

Expected Behavior

nx g lib doesn't add incompatible deps to package.json

GitHub Repo

No response

Steps to Reproduce

  1. create empty integrated workspace npx create-nx-workspace@latest nx19
  2. nx g lib foo --unitTestRunner jest --bundler tsc
  3. npm install

Nx Report

Node   : 20.12.2
OS     : win32-x64
npm    : 10.8.0

nx (global)        : 19.0.4
nx                 : 19.0.4
@nx/js             : 19.0.4
@nx/jest           : 19.0.4
@nx/linter         : 19.0.4
@nx/eslint         : 19.0.4
@nx/workspace      : 19.0.4
@nx/devkit         : 19.0.4
@nx/eslint-plugin  : 19.0.4
@nrwl/tao          : 19.0.4
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

~\temp\nx19 (main* |+0 ~1 -0)
> nx g lib foo --unitTestRunner jest --bundler tsc

 NX  Generating @nx/js:library

Fetching prettier...
Fetching @nx/eslint...
Fetching @nx/jest...
CREATE tsconfig.base.json
CREATE .prettierrc
CREATE .prettierignore
UPDATE .vscode/extensions.json
UPDATE package.json
CREATE foo/tsconfig.json
CREATE foo/src/index.ts
CREATE foo/src/lib/foo.spec.ts
CREATE foo/src/lib/foo.ts
CREATE foo/tsconfig.lib.json
CREATE foo/README.md
CREATE foo/package.json
UPDATE nx.json
CREATE foo/project.json
CREATE .eslintrc.json
CREATE .eslintignore
CREATE foo/.eslintrc.json
CREATE jest.preset.js
CREATE jest.config.ts
CREATE foo/jest.config.ts
CREATE foo/tsconfig.spec.json

added 247 packages, removed 1 package, changed 1 package, and audited 606 packages in 10s

81 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

 NX   👀 View Details of foo

Run "nx show project foo --web" to view details about this project.


~\temp\nx19 43s (main* |+0 ~4 -0)
> npm i
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: @swc-node/core@1.13.1
npm warn Found: @swc/core@1.3.107
npm warn node_modules/@swc/core
npm warn   dev @swc/core@"~1.3.85" from the root project
npm warn   3 more (@swc-node/register, nx, ts-node)
npm warn
npm warn Could not resolve dependency:
npm warn peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm warn node_modules/@swc-node/core
npm warn   @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm warn   node_modules/@swc-node/register
npm warn
npm warn Conflicting peer dependency: @swc/core@1.5.7
npm warn node_modules/@swc/core
npm warn   peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm warn   node_modules/@swc-node/core
npm warn     @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm warn     node_modules/@swc-node/register

added 2 packages, changed 2 packages, and audited 608 packages in 2s

81 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Package Manager Version

No response

Operating System

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

Additional Information

Similar to #19386

@Den-dp
Copy link
Contributor Author

Den-dp commented May 21, 2024

I am leaning towards to @daiscog idea:

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.

What if we stop adding @swc/core and @swc-node/register as explicit dependencies of package.json? Are there any downsides?

@xiongemi
Copy link
Collaborator

i think after upgrading @swc/packages to latest, the warnings should go away:

    "@swc-node/register": "~1.9.1",
    "@swc/cli": "0.3.12",
    "@swc/core": "~1.5.7",

FrozenPandaz pushed a commit that referenced this issue May 27, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
npm warnings:
```
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @swc-node/core@1.13.1
npm WARN Found: @swc/core@1.3.107
npm WARN node_modules/@swc/core
npm WARN   dev @swc/core@"~1.3.85" from the root project
npm WARN   3 more (@swc-node/register, nx, ts-node)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm WARN node_modules/@swc-node/register/node_modules/@swc-node/core
npm WARN   @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm WARN   node_modules/@swc-node/register
npm WARN 
npm WARN Conflicting peer dependency: @swc/core@1.5.7
npm WARN node_modules/@swc/core
npm WARN   peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm WARN   node_modules/@swc-node/register/node_modules/@swc-node/core
npm WARN     @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm WARN     node_modules/@swc-node/register
```

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #23688
ndcunningham pushed a commit that referenced this issue May 28, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
npm warnings:
```
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @swc-node/core@1.13.1
npm WARN Found: @swc/core@1.3.107
npm WARN node_modules/@swc/core
npm WARN   dev @swc/core@"~1.3.85" from the root project
npm WARN   3 more (@swc-node/register, nx, ts-node)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm WARN node_modules/@swc-node/register/node_modules/@swc-node/core
npm WARN   @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm WARN   node_modules/@swc-node/register
npm WARN 
npm WARN Conflicting peer dependency: @swc/core@1.5.7
npm WARN node_modules/@swc/core
npm WARN   peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm WARN   node_modules/@swc-node/register/node_modules/@swc-node/core
npm WARN     @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm WARN     node_modules/@swc-node/register
```

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #23688
FrozenPandaz pushed a commit that referenced this issue May 28, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
npm warnings:
```
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @swc-node/core@1.13.1
npm WARN Found: @swc/core@1.3.107
npm WARN node_modules/@swc/core
npm WARN   dev @swc/core@"~1.3.85" from the root project
npm WARN   3 more (@swc-node/register, nx, ts-node)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm WARN node_modules/@swc-node/register/node_modules/@swc-node/core
npm WARN   @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm WARN   node_modules/@swc-node/register
npm WARN
npm WARN Conflicting peer dependency: @swc/core@1.5.7
npm WARN node_modules/@swc/core
npm WARN   peer @swc/core@">= 1.4.13" from @swc-node/core@1.13.1
npm WARN   node_modules/@swc-node/register/node_modules/@swc-node/core
npm WARN     @swc-node/core@"^1.12.0" from @swc-node/register@1.8.0
npm WARN     node_modules/@swc-node/register
```

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #23688

(cherry picked from commit a6e23c1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants