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

doesn't work with npm exec --workspaces npx ncu #896

Closed
3 tasks done
mesqueeb opened this issue May 26, 2021 · 10 comments
Closed
3 tasks done

doesn't work with npm exec --workspaces npx ncu #896

mesqueeb opened this issue May 26, 2021 · 10 comments

Comments

@mesqueeb
Copy link

  • I have searched for similar issues
  • I am using the latest version of npm-check-updates
  • I am using node >= 10.17

Steps to Reproduce

npm exec --workspaces npx ncu --target minor -u

Current Behavior

Here you can see:

  • it does execute in all my NPM 7 workspace packages, but it doesn't seem to work.
  • underneath the execution via the npm script, using lerna does work as expected.

Screenshot 2021-05-26 at 10 28 23

Expected Behavior

To work with NPM 7 --workspaces flag. I'd love to stop using lerna since there's 0 merit over just native NPM 7 workspaces.

Let me know if I can help with anything else for further clarification : )

@raineorshine
Copy link
Owner

Could you try:

npm exec --workspaces -- npx ncu --target minor -u

Based on npx vs npm exec arg parsing:
https://docs.npmjs.com/cli/v7/commands/npm-exec#npx-vs-npm-exec

If that doesn’t work, try installing npm-check-updates globally and removing npx from the equation for better isolation of the problem.

npm install -g npm-check-updates
npm exec --workspaces -- ncu --target minor -u

If it is still an issue I can try to reproduce it on my side, but npm-check-updates shouldn’t require anything special for --workspaces to work if it works correctly on its own.

@mesqueeb
Copy link
Author

mesqueeb commented May 30, 2021

@raineorshine thanks!

  • npm exec --workspaces -- npx ncu --target minor -u
  • npm exec --workspaces -- ncu --target minor -u

these two worked! I have ncu in the root devDependencies so went with the latter one!

@kai-dorschner-twinsity
Copy link

You could also use the --deep flag instead.

@leojh
Copy link

leojh commented Feb 2, 2022

be on the lookout that npx ncu will run a weather app. when using npx, reference the full qualified package name npm-check-updates as per the README

@raineorshine
Copy link
Owner

Native workspace support added in prerelease v16.2.0-0. Open for feedback :). Your help is much appreciated in finding unidentified edge cases.

npx npm-check-updates@v16.2.0-0 --workspaces

How it works

Upgrade all workspaces:

ncu --workspaces
ncu -ws

Upgrade a single workspace:

ncu --workspace a
ncu -w a

Upgrade more than one workspace:

ncu --workspace a --workspace b
ncu -w a -w b

Upgrade all workspaces AND the root project:

ncu --withWorkspaces
ncu -wws

Upgrade a single workspace AND the root project:

ncu --withWorkspace a
ncu -ww a

Notes

@mesqueeb
Copy link
Author

@raineorshine thanks for this great feature!

I would love to give some feedback on the syntax.

I believe it's easier to understand the command later, instead of --withWorkspaces, to keep the --workspaces command, but adding an extra one for the root.

current

ncu --withWorkspaces

suggested

ncu --workspaces --withRoot

or

ncu --workspaces --root

It's just my personal opinion but I think reading this makes it easier to understand.

@raineorshine
Copy link
Owner

raineorshine commented Sep 17, 2022

I do like how that looks. Thanks for the suggestion!

I was also thinking of utilizing an existing option:

ncu --workspaces --packageFile ./package.json

But I feel like this will be a common command and deserves to have a shorter syntax.

@raineorshine
Copy link
Owner

Published to latest on v16.3.0.

I changed --withWorkspaces to --workspaces --root (and --withWorkspace to --workspace X --root). Thanks for the suggestion!

@mesqueeb
Copy link
Author

@raineorshine

thanks for this update.

It seems like with this new command NCU gets confused about what packages local workspace packages are and which ones aren't:

image

it seems to be looking for my workspace packages like @cc/auth etc, on NPM, while instead it should ignore those.

with npm exec --workspaces -- ncu --target minor I don't think I had this issue

should I open a new ticket for this?

@mesqueeb mesqueeb reopened this Sep 24, 2022
@raineorshine
Copy link
Owner

Yes, please open a new ticket. Make sure to include:

  1. Your dependencies list
  2. The value of workspaces from your package.json
  3. Why you believe @cc/auth should be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants