npm installation displays a variety of colors on Docker Hub during the installation process

When attempting npm install in a Dockerfile, I thought disabling the colors would eliminate color codes in the Dockerhub build logs. However, that doesn't seem to be the case.

Can anyone point out where I might have gone wrong?

To see the details of the build, you can refer to the Dockerfile on Docker Hub:

Dockerfile:

FROM node
MAINTAINER  Attila Szeremi <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88e9fcfce1e4e9a3ffedeaecedfec8fbf2edfaede5e1a6ebe7e5">[email protected]</a>>
RUN mkdir /src
WORKDIR /src
RUN cd /src
# Copy just the package.json file file as a cache step.
COPY package.json /src/package.json
# Disable progress so npm would install faster.
# Disable colors, because Dockerhub can't display them.
# Install NPM packages excluding the dev dependencies.
RUN npm set progress=false && npm set color=false && npm install --production

COPY . .
RUN npm run build
EXPOSE 8080
CMD ["npm", "run", "start"]

Sample output from the build script:

Step 3 : WORKDIR /src
 ---> Running in 4a8ec4902bee
 ---> ce66cec7780b
Removing intermediate container 4a8ec4902bee
Step 4 : RUN cd /src
 ---> Running in 561c6d10cdb8
 ---> c12b27e7c01a
Removing intermediate container 561c6d10cdb8
Step 5 : COPY package.json /src/package.json
 ---> ebbb940c8911
Removing intermediate container c39be008ad46
Step 6 : RUN npm set progress=false && npm set color=false && npm install --production
 ---> Running in c9ebee32f367
[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91mit worked if it ends with[0m[91m ok
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91musing[0m[91m <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a342a371a697469746b68">[email protected]</a>
[0m[91mnpm[0m[91m [0m[91minfo[0m[91m [0m[91musing[0m[91m <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3cdccc7c6e3d5968d968d93">[email protected]</a>
...

Answer №1

After trying multiple solutions, I finally found success with the command npm install 2>&1. The detailed explanation and support for this solution can be found on this GitHub page.

Answer №2

FROM node refers to utilizing node 6.5 version (most current as of Sept 2016)

As explained in issue 225, this particular version includes a progress bar (which you may have attempted to turn off) and a spinner.

Experiment with the following simple test scenarios:

FROM node:6.4.0

ENV NPM_CONFIG_PROGRESS false
ENV NPM_CONFIG_SPIN false

WORKDIR /app

RUN npm install express

Alternatively, by copying a .npmrc file with:

progress=false
spin=false

Or by including --color false directly in the npm install command:

 npm --color false install --production

If none of these methods work, consider reopening issue 225, which is the most recent bug report related to this matter.

You could also try running the job in Jenkins using the AnsiColor Plugin to offer some level of support.


Since this response was provided in Oct. 2016, reference to issue 225 highlights:

The issue stems from Jenkins not fully supporting ANSI escape sequences in the console output.
Any STDERR output in your Dockerfile appears in red during docker build. Following advice from @tianon, consider using the AnsiColor+Plugin to rectify this.

An alternate workaround involves ignoring any output, as suggested by Zack Steinkamp in this comment within issue 225 through RUN npm install 2>&1.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to retrieve the current directory in npm scripts?

Consider a scenario where the package.json for my projects is located as follows: project |- package.json Now, imagine that I run an npm script from a different location within the project structure: project |- package.json |- some |- nested |- ...

How can user input be captured in the terminal following the execution of npm start?

Imagine a basic program running in the background. Here is a simple simulation (index.js). process.stdin.resume(); console.log('just hanging...') If you run it with node index.js, nothing else will happen until you exit with ctrl+c. Even though ...

Error encountered while attempting to install ungit on Windows XP: Unable to locate file directory in C:/Documents

Ungit seems like the ideal tool to gain a better understanding of git, thanks to its graphical interface that simplifies the process. I came across this video explanation which is very helpful in grasping how git functions, even if you don't intend to ...

There was a problem encountered while trying to download and extract the project files. The response body was invalid, displaying a message like "blah" and indicating an EACCES error

I've encountered an issue while trying to set up my expo project. Despite using nvm with node v14.16.1 (npm v7.11.2), I kept receiving the following error: expo init Doorgy ✔ Choose a template: › minimal bare and minimal, just the es ...

The compilation of PKG using Axios 1.x encounters an error

Despite attempting numerous strategies, I have not been successful. I developed a Node.js application with API requests managed using axios. However, I am unable to convert it into an executable file. Trying to downgrade Axios to version 0.27.0 resolved th ...

Set up a host node module on your local server and integrate it into your application by installing it via

Currently, I am in the process of developing a node package with the following structure: my_module(folder) --package.json (located inside the my_module folder) --other files/folder (contained within the my_module folder) The contents of the package.jso ...

Accessing the various types within a monorepo from a sibling directory located below the root folder

Seeking assistance in resolving a referencing types issue within a TypeScript monorepo project. Unsure if it is feasible given the current setup. The project structure is as follows: . ├── tsconfig.json ├── lib/ │ └── workers/ │ ...

Error: Unable to locate the NPM module for grunt sass

Uh oh, it looks like the local Npm module "grunt-sass" is missing. Have you installed it? Executing the "serve" task. Executing the "clean:server" (clean) task. 0 paths have been cleaned. Executing the "generateConstantsFileWithConfig" task. Executi ...

The error message that is popping up on Windows when running `npm start` is

Hey there! I'm having an issue with my Windows 10 installation and Mean. After installing express, I tried to start npm using the command "npm start" but encountered the following error: C:\>npm start npm ERR! Windows_NT 6.3.9600 npm ERR! arg ...

Encountering a gyp build error while trying to run npm install

Struggling to configure node and git for a web project, despite installing node from their official website. When attempting npm install on the git project, an error is encountered: C:\Users\Jibran\Desktop\ekhadim\ekhadimweb>np ...

When npm prune is used to remove unused packages, it can potentially break the build. What other options are available

Encountered strange behavior while using npm prune in node version 5/6 with npm version 3.8.6: it deletes packages that are being used, resulting in a broken build. Here is the list of dependencies: "dependencies": { "browser-sync": "^2.11.1", ...

Error in TypeScript when utilizing an Enum as a string

Attempting to include a string enum in my Angular 2 project resulted in an error during the npm project startup: ERROR in e:/projects/dbtool-fullstack/dbtool-client/src/app/shared/models/full-m odels/enums/Sex.ts (2,10): Type '"Male"' is not ass ...

The reason for the failure of npm install in Express.js is due to an issue with getaddrinfo E

For the past two years, I have been running a Node.JS / Express.JS server-side program inside a Node.JS docker container without any issues. However, recently upon installation, it started throwing a strange error. I typically use docker-compose to install ...

I encounter the error message "Class extends value undefined is not a constructor or null" in sveltekit when attempting to import a function from npm modules that I previously exported

I am struggling to send emails using SvelteKit and the "nodemailer" npm module. However, when I try to import the function, I encounter an error: "Class extends value undefined is not a constructor or null" Here is the code snippet from my mail.js file: i ...

Setting up the Imager npm module

Recently I've encountered a strange situation where the npm package along with GraphicsMagick library mysteriously disappeared from my computer (but that's a story for another time). After reinstalling the library, I tried running sudo npm in ...

What could be causing the failure of this build when NODE_ENV is configured for production?

I encountered an issue where the npm install command was not functioning properly when the NODE_ENV variable was set to production. Since my knowledge of Node is limited, I am reaching out for help to understand why this problem might be occurring. Here a ...

Electron JS-powered app launcher for seamless application launching

Currently, I am working on a project to develop an application launcher using HTML, CSS, and JS with Electron JS. Each application is linked through an a href tag that directs users to the respective application path. If a normal link is used in the a hr ...

I'm trying to figure out which one is the correct term on Ubuntu - is it "node" or "nodejs"? And

Trying to install webpack-dev-server but it requires the latest version of nodejs. I am using Ubuntu 20.04 and attempted to update with nvm, which did not work. Following this Q&A answer here, I then tried to install nodejs using sudo apt-get install ...

Retrieve all records in which a Sequelize association uses hasOne

Currently, I am exploring the `sequalize association - hasOne` feature. However, I encountered an unexpected issue where all the rows from the `USER` table are being returned instead of just the rows from the `system_admin` table. Is this the intended beha ...

Error message encountered during NPM installation on Windows 10: Protocol not recognized or missing

Whenever I attempt to install packages using NPM on Windows 10, I encounter the following error message: Error: Invalid protocol : null Has anyone else experienced this issue before? https://i.stack.imgur.com/DdlmR.png ...