I'm using the node:6.7.0 image as my docker container and then follow the installation guide for yarn
sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then I do
apt-get update && apt-get install yarn
But at this point I get an error message which says
yarn : Depends: nodejs (>= 4.0.0) but it is not going to be installed
I've echoed node -v
before the install and it also says 6.7.0
Anything that I'm missing?
Running Docker containers on YARN works very similar to running existing containers. Containers have access to files that are localized for the container as well as logging. You can deploy a load balanced web server pair on a single node HDP cluster using the YARN Services API .
Dependencies can be defined between containers in the same pod, where the dependencies are specified by container names. Docker containers are started and stopped according to user-defined dependencies, or in arbitrary order if no dependencies are defined.
The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations.
To solve the error "yarn: command not found", install the yarn package globally by running npm install -g yarn and restart your terminal. If the command fails, run it with sudo and make sure the correct PATH is set in your system's environment variable.
Let's start by creating a folder for our project and initialise yarn mkdir yarn-docker-setup cd yarn-docker-setup yarn init -p If you do not have yarn installed already, you can install by npm install yarn -g. After filling out basic questions, you would have a package.json file.
There are many options for installing dependencies, including: 1 Installing all dependencies: yarn or yarn install 2 Installing one and only one version of a package: yarn install --flat 3 Forcing a re-download of all packages: yarn install --force 4 Installing only production dependencies: yarn install --production More ...
Install via npm It is recommended to install Yarn through the npm package manager, which comes bundled with Node.jswhen you install it on your system. Once you have npm installed you can run the following both to installand upgradeYarn: npm install --globalyarn
These files rarely change in the course of the project, so if we install our dependencies once, and if they don't change the next time we build, Docker will use the existing cache and not run yarn install every-time we build. This will significantly reduce our build times. The next step is to copy the app's code and build.
robertklep is right - if you check the Dockerfile for Node you'll see they install Node by downloading the TAR, not through APT. You can check this by running an interactive container:
> docker run -it node:6.7.0 bash
root@465fa07437c9:/# dpkg -s nodejs
dpkg-query: package 'nodejs' is not installed and no information is available
You can use NPM in your Dockerfile instead:
FROM node:6.7.0
RUN npm install -g yarn
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