I'm new to Docker and I faced with a problem on windows,
I get an error while running npm i
on my docker machine:
panel_1 | > [email protected] install /var/www/html/node_modules/phantomjs-prebuilt
panel_1 | > node install.js
panel_1 |
panel_1 | module.js:550
panel_1 | throw err;
panel_1 | ^
panel_1 |
panel_1 | Error: Cannot find module 'readable-stream'
panel_1 | at Function.Module._resolveFilename (module.js:548:15)
panel_1 | at Function.Module._load (module.js:475:25)
panel_1 | at Module.require (module.js:597:17)
panel_1 | at require (internal/module.js:11:18)
panel_1 | at Object.<anonymous> (/var/www/html/node_modules/concat-stream/index.js:1:78)
panel_1 | at Module._compile (module.js:653:30)
panel_1 | at Object.Module._extensions..js (module.js:664:10)
panel_1 | at Module.load (module.js:566:32)
panel_1 | at tryModuleLoad (module.js:506:12)
panel_1 | at Function.Module._load (module.js:498:3)
My compose:
panel:
build: './panel'
volumes:
- ./panel:/var/www/html
command: make init_dev
My Dockerfile:
FROM php:7.2-fpm
RUN apt-get update && apt-get install -y \
openssl \
git \
unzip \
libzip-dev \
wget \
gnupg
# NodeJs
RUN wget -qO- https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs
RUN apt-get install -y build-essential
# Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install mysqli pdo pdo_mysql zip bcmath
WORKDIR /var/www/html
makefile init_dev:
composer install
npm i
npm run dev
Already spent a day on resolving it. I tried to downgrade Phantomjs / upgrade npm / change permission for global node_modules but nothing helped. On local it's OK.
Just found that npm installation goes successful without using volumes
.
Seems it happens due to windows mounted folder. Because there are no support for symlinks which npm is trying to add. My workaround looks like this:
COPY . /var/www/temp
WORKDIR /var/www/temp
RUN npm i
WORKDIR /var/www/html
And then I just do a copy of finished modules with CMD:
cp -r ../temp/node_modules ./
Looks like a crutch, but mb it'll help somebody