2 Methods to Disable ANSI Color Escape Codes for npm

2 Methods to Disable ANSI Color Escape Codes for npm

By default, npm uses ANSI color escape codes in terminal output to make logs and messages easier to distinguish. Colored output enhances readability, but plain text is more suitable in some environments. This tutorial provides 2 methods how to disable ANSI color escape codes for npm.

Method 1 - no-color option

The npm includes a built-in --no-color option that suppresses ANSI color escape codes for a single command execution. The option can be used with any npm command. For example, to install project dependencies without colored output:

npm --no-color install

Method 2 (Linux) - NO_COLOR before command

Another option is to define the NO_COLOR environment variable for the current command. When this variable is present, npm produces plain text output instead of colored terminal messages.

NO_COLOR=1 npm install

Leave a Comment

Cancel reply

Your email address will not be published.