Cannot set npm dependencies when creating docker image

I create an image from a Docker file, and the part where I install the dependencies, I am mistaken when I create an image, but I can run commands outside it. I don’t know exactly where this error came from.

I am using boot2docker for Windows and my Docker file:

FROM ubuntu:15.04 RUN apt-get -y update RUN apt-get -y install nodejs RUN apt-get -y install npm COPY /server /src COPY /server/package.json /tmp/package.json RUN cd /tmp && npm install (etc) 

Error message:

 sh:1 node: not found npm WARN: This failure might be due to the use of legacy binary "node" npm WARN: For further explanations, please read /usr/share/doc/nodejs/README.Debian npm ERR! sails@0.11.0 preinstall: 'node ./lib/preinstall_npmcheck.js' npm ERR! Exit status 127 npm ERR! npm ERR! Failed at the sails@0.11.0 preinstall script. npm ERR! This is most likely a problem iwth the sails package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node ./lib/preinstall_npmcheck.js npm ERR! You can get their info via: npm ERR! npm owner ls sails npm ERR! There is additional logging output above. npm ERR! System Linux 4.0.3-boot2docker npm ERR! command "usr/bin/nodejs" "/usr/bin/npm" "install" npm ERR! node -v v0.10.25 npm ERR! npm -v 1.4.21 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /tmp/npm-debug.log npm ERR! not ok code 0 INFO[0633] THe command [/bin/sh -c cd /tmp && install] returned a non-zero code: 1 

Although he says this is probably a problem with Sails, I have no problem installing it on my machine. I cannot install it when I run the image (obviously), and when I try to just run the ubuntu image: 15.04 and install npm and Sails there, it tells me that npm is command not found .

I'm still new to Docker (and on Windows - I can't even find npm-debug.log), so any type of advice helps a lot.

Thanks!

+5
source share
1 answer

This is the nodejs installation issue that was discussed here: what are the differences between node.js and node?

In short, there are three options to fix this: create a symbolic link yourself using nvm or install nodejs-legacy instead of nodejs :

RUN apt-get -y install nodejs-legacy

+6
source

All Articles