raineorshine / npm-check-updates

Find newer versions of package dependencies than what your package.json allows
Other
9.33k stars 323 forks source link

Incorrectly waits for stdin #136

Closed Igloczek closed 1 year ago

Igloczek commented 8 years ago

Looks like ncu is currently not compatible with Node v4.1.0. I can run ncu, but nothing happens - cursor just goes to new line.

angeldelacruzdev commented 4 years ago

Hey guys, this command worked out for me. Using gitbash MinTTY. Try running this command ncu -u --packageFile package.json npm-check-updates

This Working

KingDarBoja commented 4 years ago

Any progress on this issue? Just curious... The provided workaround does work on Win 10 with Git Bash.

raineorshine commented 4 years ago

@KingDarBoja I don't believe anyone is actively working on this. Open to pull requests though.

KingDarBoja commented 4 years ago

@raineorshine Managed to solve the problem based on @kylios comment as I noticed the if-else check at findPackage function didn't took into account the pkgFileName value as it was set to default on getPackageFileName.

Something like this:

// ... More code
if (options.packageData) {
        pkgFile = null;
        pkgData = Promise.resolve(options.packageData);
    } else if (options.packageFile) {
        pkgFile = options.packageFile;
        pkgData = getPackageDataFromFile(pkgFile, pkgFileName);
    } else if (pkgFileName) { // extra check added :D 
        pkgFile = pkgFileName;
        pkgData = getPackageDataFromFile(pkgFile, pkgFileName);
    } else if (!process.stdin.isTTY) {
        // ... More code
    }
//... More code

Proof: image

raineorshine commented 4 years ago

pkgFileName is always truthy, thus the code proposed would never reach if (!process.stdin.isTTY) { ... }, breaking stdin functionality. We need a solution that correctly detects isTTY across platforms.

stoically commented 4 years ago

Personally I think it might make sense to make reading from stdin opt-in, as breaking change. Since arguably reading from stdin is the much less used branch.

raineorshine commented 4 years ago

That makes sense to me.

KingDarBoja commented 4 years ago

@raineorshine I know but as most users have to provide the package filename by using the --packageFile option, it doesn't make sense to step into the process.stdin.isTTY part.

@stoically makes sense if someone wish to use it, as a new flag which should take priority over the existing checks and everyone would (I think) be happy about it.

KingDarBoja commented 3 years ago

No idea what changed on this library or my git bash but I no longer need --packageFile to make it work 🚀

raineorshine commented 3 years ago

@KingDarBoja Interesting. If an old version of ncu such as v2 works for you now, then it's your shell. Otherwise I'd be curious what exact version of ncu it started working for you.

KingDarBoja commented 3 years ago

@KingDarBoja Interesting. If an old version of ncu such as v2 works for you now, then it's your shell. Otherwise I'd be curious what exact version of ncu it started working for you.

I updated this week to 10.2.1 that's why I am surprised its working out of the box.

raineorshine commented 3 years ago

Well that's good news at least. It's unclear whether it's node, npm, ncu, or one of ncu's dependencies that fixed it. If someone else can confirm I'll close the issue!

ncepuee commented 3 years ago

I installed node v4.1.0 and ran ncu without a problem. All unit tests passing, too.

What happens when you run this command?

echo '{"dependencies":{"express": "1"}}' | ncu

Please provide any additional information you can about the problem.

hi,i meet with the problem: my environment is:

NexT version 8.0.0
Documentation: https://theme-next.js.org
========================================
hexo: 5.3.0
hexo-cli: 4.2.0
os: Windows_NT 10.0.19041 win32 x64
node: 14.15.4
v8: 8.4.371.19-node.17
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.16.1
modules: 83
nghttp2: 1.41.0
napi: 7
llhttp: 2.1.3
openssl: 1.1.1i
cldr: 37.0
icu: 67.1
tz: 2020a
unicode: 13.0

and i use the code npm i -g npm-check-updates to install the package it succeed,and then i use the git bash in my blog root directory,use ncu or ncu -u,it display this:

$ ncu -u
Hmmmmm... this is taking a long time. Your console is telling me to wait for input
on stdin, but maybe that is not what you want.
Try winpty ncu.cmd, or specify a package file explicitly with --packageFile package.json.
See https://github.com/raineorshine/npm-check-updates/issues/136#issuecomment-155721102

i see this issue,so which is the answer to this problem?

raineorshine commented 3 years ago

@hizablet Specify --packageFile package.json.

donocode commented 3 years ago

Just in case anyone ends up here while trying to run ncu through execa, you can make things work correctly with the stdin option:

execa('ncu', { preferLocal: true, stdin: process.stdin })

For some reason it does not work without it and only when piping stdout are you able to get a warning message which links here.

raineorshine commented 3 years ago

trying to run ncu through execa

(As an aside, you can require npm-check-updates which may work better in some circumstances if you're willing to have it as a local dependency.)

tmarcinkowski-logitech commented 2 years ago

For anyone using concurrently and experiencing this issue as well - you either need to explicitly set --packageFile as said before, or pass --raw option to concurrently (but you lose prefixing in this case).

An example:

npx concurrently \
  -n root,common,ui,api \
  "npx npm-check-updates --packageFile package.json" \
  "npx npm-check-updates --packageFile package.json --prefix common" \
  "npx npm-check-updates --packageFile package.json --prefix ui" \
  "npx npm-check-updates --packageFile package.json --prefix api"
wangjing199196ok commented 2 years ago

I installed node v4.1.0 and ran ncu without a problem. All unit tests passing, too. What happens when you run this command?

echo '{"dependencies":{"express": "1"}}' | ncu

Please provide any additional information you can about the problem.

hi,i meet with the problem: my environment is:

NexT version 8.0.0
Documentation: https://theme-next.js.org
========================================
hexo: 5.3.0
hexo-cli: 4.2.0
os: Windows_NT 10.0.19041 win32 x64
node: 14.15.4
v8: 8.4.371.19-node.17
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.16.1
modules: 83
nghttp2: 1.41.0
napi: 7
llhttp: 2.1.3
openssl: 1.1.1i
cldr: 37.0
icu: 67.1
tz: 2020a
unicode: 13.0

and i use the code npm i -g npm-check-updates to install the package it succeed,and then i use the git bash in my blog root directory,use ncu or ncu -u,it display this:

$ ncu -u
Hmmmmm... this is taking a long time. Your console is telling me to wait for input
on stdin, but maybe that is not what you want.
Try winpty ncu.cmd, or specify a package file explicitly with --packageFile package.json.
See https://github.com/raineorshine/npm-check-updates/issues/136#issuecomment-155721102

i see this issue,so which is the answer to this problem?

Have you solved the problem yet? I have meet the same problem...

raineorshine commented 2 years ago

Auto stdin has been deprecated and will be removed in the next major version, which should fix the issue.

In the mean time, does using --packageFile package.json work for you?

raineorshine commented 1 year ago

Auto stdin removed in 7005bc6