I have a Dockerfile like below :
FROM node:latest
RUN npm install something && \
npm install something && \
npm install something
I want to pass 'yes' response for all required 'yes/no' param when npm installing. Is there any way to do this?
Test NPM. To see if NPM is installed, type npm -v in Terminal.
Use npm install to install new dependencies , or to update existing dependencies (e.g. going from version 1 to version 2). Use npm ci when running in continuous integration, or if you want to install dependencies without modifying the package-lock.
The -y flag when passed to NPM commands tells the generator to use the defaults instead of asking questions. npm init -y. will simply generate an empty npm project without going through an interactive process. The -y stands for yes . More about npm-init here.
By default, npm install will install all modules listed as dependencies in package. json .
If you fail to remove your .npmrc file from your Dockerfile, it will be saved in your Docker image. It will exist on the file system of any Docker container you create from that image. Here’s a Dockerfile where we create an .npmrc file but fail to delete it after running npm install:
On February 24th, 2019 I published a follow-up post about using Docker build secrets instead of multi-stage builds. I recommend reading that post after this one! I recently completed a security audit of Docker images for a project. These images used .npmrc files ( npm config files) to download private npm packages.
Running npm install without arguments installs modules defined in the dependencies section of the package.json file. It's important that npm install is run in the same directory as the package.json file. The downloaded modules are placed in a node_modules folder in the same location as package.json.
If an attacker compromised your Docker container they would not be able to steal your npm token. Unfortunately, each RUN instruction creates a separate layer (also called intermediate image) in a Docker image. Multiple layers make up a Docker image.
I used the following to install Angular without usage statistics sharing.
RUN echo n | npm install -g --silent @angular/cli
I think echo y
should work for you
There's the yes
command specifically for this in linux:
RUN yes | npm install something && \
npm install something && \
yes yes | npm install something
The first line outputs a list of "y" to the first npm install command. The yes
command also takes an option of what you want it to output. So if you need to output "yes" instead of a single "y" character per line, then you can run yes yes
as seen in the third example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With