Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Implement silent param for install/uninstall commands #7990

Closed
marcominetti opened this issue Apr 17, 2015 · 8 comments
Closed

Implement silent param for install/uninstall commands #7990

marcominetti opened this issue Apr 17, 2015 · 8 comments

Comments

@marcominetti
Copy link

When using npm programmatically as module, install and uninstall does not accept any silent param. Just for example list command supports it.

@smikes
Copy link
Contributor

smikes commented Apr 17, 2015

If you want npm to write minimal output when installing, you can set the loglevel parameter to silent:

$ npm --loglevel=silent install

However, npm will still write to standard output and standard error. On a unix-like system such as Linux or OSX, you can suppress this output as well:

$ npm --loglevel=silent install 2>&1 >/dev/null

@marcominetti
Copy link
Author

Thanks, but I'm using it programmatically through

var npm = require('npm');

Do you have a quick hint to initialize with log level silent in npm.load?

@smikes
Copy link
Contributor

smikes commented Apr 17, 2015

Sure

npm.load( {loglevel: "silent"}, function … )

But you should be careful, as the npm api is intended for internal use, and project policy allows npms api to change without affecting semver; semver applies only to the command line interface and behavior.

@marcominetti
Copy link
Author

Yep, I know... I will probably fork it for internal use and manage lifecycle directly... ;) Thanks!

@marcominetti
Copy link
Author

Perfect,

npm.load( {loglevel: "silent"}, function … )

does exactly fit my needs.

Thanks...

;)

@mattdesl
Copy link

Testing with npm@2.8.4 and npm.commands.install does not seem to respect loglevel or silent options on npm.load. Ideas?

@marcominetti
Copy link
Author

Hi @mattdesl, just to confirm we're talking about the same thing...

With the snippet above we define log level silent that works only for console log from npm... All the logs you see at stdout when loglevel is silent should come directly from nodegyp or any other process (npm itself too) spawned with child stdio piped to your process.stdio...

Did I understand correctly @smikes?

@wilk
Copy link

wilk commented Dec 26, 2017

Like @mattdesl said, I've the same problem with npm@5.6.0 and npm.commands.install

screen shot 2017-12-26 at 11 55 36

Between "done!" and "done!" there's another debug line printed with process.stdout.write (yes, you cannot see it): it seems that only console.log is working after the npm.commands.install gets executed.
The stdout buffer remains dirty, as you can see from the screenshot, preventing the user to use the command line without problems.

Is this a regression bug?

UPDATE
Solved with progress option.

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

No branches or pull requests

4 participants