5

I'm building an image from a Dockerfile and the part where I npm install the dependencies is erroring when I build the image, but I can run the commands outside of it. I don't know exactly where this error is coming from.

I'm using boot2docker on Windows and my Dockerfile is:

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)

The error message is:

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 it says it's probably a problem with Sails, I have no problem installing it on my machine. I can't install it when I run the image (obviously), and when I try to just run the ubuntu:15.04 image and install npm and Sails there, it tells me that npm is a command not found.

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

Thank you!

Mina Han
  • 671
  • 2
  • 10
  • 17

1 Answers1

6

It's a problem of nodejs installation which was covered here: what are the differences between node.js and node?

Breifly, there are three options to fix this: creating symlink yourself, using nvm, or installing nodejs-legacy instead of nodejs:

RUN apt-get -y install nodejs-legacy

Community
  • 1
  • 1
Alex V
  • 1,155
  • 8
  • 10