我正在尝试使用npm的终端进度条来更好地可视化长时间进程的进展。当我从标准的“node index.js”运行它时,一切顺利,但是当从简单的docker镜像运行时,终端上没有任何内容显示。我的index.js代码如下:
const _cliProgress = require('cli-progress');
// create a new progress bar instance and use shades_classic theme
const bar1 = new _cliProgress.Bar({}, _cliProgress.Presets.shades_classic);
// start the progress bar with a total value of 200 and start value of 0
bar1.start(200, 0);
// update the current value in your application..
bar1.update(100);
// stop the progress bar
bar1.stop();
这是我的 Docker 文件:
FROM node:latest
#create work directory
RUN mkdir -p /src
#establish the app folder as the work directory
WORKDIR /src
COPY package.json /src
COPY package-lock.json /src
RUN npm i
COPY . /src
CMD [ "node", "index.js" ]
终端没有显示这些软件包的任何信息,但是可以显示正常的console.logs。我尝试使用其他的软件包时也存在这个问题。如果有关于为什么出现了与预期不同的结果的任何信息,将不胜感激。谢谢。
tty: true
。 - Marcos Casagrande