npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

``npm ci`` logs success to stderr

What I Wanted to Do

Use npm ci on CI instead of npm install. I expected to be a drop-in replacement.

What Happened Instead

The command logs the summary to stderr, which is treated as an ERROR by the build system.

The command logs the summary to stderr, which is treated as an ERROR by the build system.

With all due respect, your build system is doing it wrong. stderr is just the name of a pipe, it doesn’t have any semantic meaning such as “an error occurred in this process”. stderr is where well-behaved CLI programs emit their logging, and the exit code of the process is where a build system should check if there was an error or not (by convention, shell processes exit non-zero when an error occurred).

Doesn’t bother you that the function called is console.error? That’s a pretty good hint that it is for priting error messages. Please show me a UNIX tool that prints a success message to stderr.

Also, the same message is printed by npm install using console.log. Why ci and ``install` would print the same messages to different pipes?

It’s pretty common practice to print human-oriented data out to stderr rather than stdout. This particular one, as the completion value of the install, is fine to spit out to stdout, but it’s really not meant to be parsed/consumed.

If you care about this, I’d accept a patch that changes this console.error to a console.log!

p.s. @evocateur it’s worth noting that a lot of build systems, specially Windows-based systems, consider any log output to stderr to be an error. While *nix best practice is to just let stderr be whatever, Windows practice is different, and we do support that environment. :slight_smile:


I just made a PR:

Lerna, for one. Anyone who uses npmlog, for that matter. It’s a log message, not program output.