Performing a npm install via Docker on a windows host

时间秒杀一切 提交于 2019-12-04 02:45:16
Tomasz Jakub Rup

Instead of

RUN npm install --global gulp -y

use

RUN sudo npm install --global gulp -y

You try to install gulp as a global package from user node (not superuser).

Or install gulp before switch user to node.

USER node
RUN npm install --global gulp -y

EDIT:

boot2docker is based on VirtualBox. Virtualbox does not allow symlinks on shared folders for security reasons.

To enable symlinks You must set VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME to 1. (Here is link to description how to do it on Vargrant: Symbolic links and synced folders in Vagrant)

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

Replace VM_NAME and SHARE_NAME and restart VirtualBox.

Another solution is add --no-bin-link to npm:

RUN npm install -g bower --no-bin-link
RUN npm install --global gulp -y --no-bin-link

EDIT 2

By default Windows 7 security policy does not allow creating symlinks as it's a potential security threat. If user is not in Administrators group run secpol.msc and navigate to Local Policies-User Rights Assignments and add your user to Create symbolic links.

If your user belongs to Administrators group then start VirtualBox with Run as Administrator.

You can mount node_modules as a volume, so it will be a Linux filesystem inside the Docker container. Add this to your Dockerfile:

VOLUME /var/www/site/node_modules

You will see the directory at C:Users/Public/site/node_modules because it is necessary for a mount point, but you will not see any contents unless you are inside the container.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!