Docker上的Laravel Mix:ETXTBSY:文本文件正忙

时间:2018-06-28 10:08:03

标签: node.js laravel docker npm

我正在尝试在Docker容器上运行Laravel Mix。

我设法安装了npm和node的最新版本(感谢Laradock)。

现在,当我尝试运行npm install时,会得到很多这样的信息:

npm WARN rollback Rolling back express@4.16.3 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/srv/app/node_modules/express/package.json.3619593601' npm WARN rollback Rolling back array-flatten@1.1.1 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/srv/app/node_modules/express/node_modules/array-fla tten/package.json.2934324270'

node:v10.5.0

npm:v6.1.0

Windows主机。

来宾是:Linux 2369f4b16e52 4.9.93-boot2docker#1 SMP Thu May 10 10:27:54 UTC 2018 x86_64 GNU / Linux

Dockerfile:

# this is the DEV/LOCAL dockerfile (default)
FROM php:7.2-apache


COPY apache/vhost.conf /etc/apache2/sites-available/000-default.conf

# Get an update, install some bits
RUN apt-get -yqq update \
    && apt-get -yqq install --no-install-recommends apt-utils unzip libzip-dev

RUN docker-php-ext-install pdo_mysql opcache zip \
    && a2enmod rewrite negotiation

ARG DOCKER_ENV=${DOCKER_ENV}

#if we are in dev, we need xdebug

RUN if [ ${DOCKER_ENV} = local ] || [ ${DOCKER_ENV} = dev ] || [ ${DOCKER_ENV} = development ]; then \
        pecl install xdebug-2.6.0 \
        && docker-php-ext-enable xdebug \
    ; fi

#copy our php.ini over and the composer details
COPY php/*.ini /usr/local/etc/php/conf.d/
COPY composer/composer-install.sh /tmp/composer-installer.sh

WORKDIR /tmp

#if we are in dev, run the Composer install
RUN if [ ${DOCKER_ENV} = local ] || [ ${DOCKER_ENV} = dev ] || [ ${DOCKER_ENV} = development ]; then \
        apt-get -yqq install --no-install-recommends git \
        && chmod +x composer-installer.sh \
        && ./composer-installer.sh \
        && mv composer.phar /usr/local/bin/composer \
        && chmod +x /usr/local/bin/composer \
        && su -l www-data -s /bin/sh -c "composer --version" \
    ; fi


#Need these for Laravel Mix (compiling assets) - stolen from Laradock

###########################################################################
# Node / NVM:
###########################################################################

# Check if NVM needs to be installed
ARG NODE_VERSION=stable
ENV NODE_VERSION ${NODE_VERSION}
ARG INSTALL_NODE=true
ARG INSTALL_NPM_GULP=true
ARG INSTALL_NPM_BOWER=true
ARG INSTALL_NPM_VUE_CLI=true
ARG NPM_REGISTRY
ENV NPM_REGISTRY ${NPM_REGISTRY}
ENV NVM_DIR ${PROJECT_PATH}/.nvm

RUN if [ ${INSTALL_NODE} = true ]; then \
    # Install nvm (A Node Version Manager)
    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash \
        && . $NVM_DIR/nvm.sh \
        && nvm install ${NODE_VERSION} \
        && nvm use ${NODE_VERSION} \
        && nvm alias ${NODE_VERSION} \
        && if [ ${NPM_REGISTRY} ]; then \
        npm config set registry ${NPM_REGISTRY} \
        ;fi \
        && if [ ${INSTALL_NPM_GULP} = true ]; then \
        npm install -g gulp \
        ;fi \
        && if [ ${INSTALL_NPM_BOWER} = true ]; then \
        npm install -g bower \
        ;fi \
        && if [ ${INSTALL_NPM_VUE_CLI} = true ]; then \
        npm install -g vue-cli \
        ;fi \
;fi

# Wouldn't execute when added to the RUN statement in the above block
# Source NVM when loading bash since ~/.profile isn't loaded on non-login shell
RUN if [ ${INSTALL_NODE} = true ]; then \
    echo "" >> ~/.bashrc && \
    echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
    echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm' >> ~/.bashrc \
;fi

# Add NVM binaries to root's .bashrc
USER root

RUN if [ ${INSTALL_NODE} = true ]; then \
    echo "" >> ~/.bashrc && \
    echo 'export NVM_DIR="/home/laradock/.nvm"' >> ~/.bashrc && \
    echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm' >> ~/.bashrc \
;fi

# Add PATH for node
ENV PATH $PATH:$NVM_DIR/versions/node/v${NODE_VERSION}/bin

RUN if [ ${NPM_REGISTRY} ]; then \
    . ~/.bashrc && npm config set registry ${NPM_REGISTRY} \
;fi




WORKDIR /srv/app

ps fax给出:

PID TTY      STAT   TIME COMMAND
 21 pts/0    Ss     0:00 bash
300 pts/0    R+     0:00  \_ ps fax
  1 ?        Ss     0:00 apache2 -DFOREGROUND
 16 ?        S      0:00 apache2 -DFOREGROUND
 17 ?        S      0:00 apache2 -DFOREGROUND
 18 ?        S      0:00 apache2 -DFOREGROUND
 19 ?        S      0:00 apache2 -DFOREGROUND
 20 ?        S      0:00 apache2 -DFOREGROUND

是否与此有关: “ boot2docker基于VirtualBox。出于安全原因,Virtualbox不允许在共享文件夹上进行符号链接。”

Performing a npm install via Docker on a windows host

1 个答案:

答案 0 :(得分:0)

看来npm config set registry ${NPF_REGISTRY}尚未完成,所以,也许这就是您的npm install找到ETXTBSY的原因。

尝试从Dockerfile RUN if [ ${NPM_REGISTRY} ]; then \ . ~/.bashrc && npm config set registry ${NPM_REGISTRY} \ ;fi中删除 并在npm install之前手动执行它,看看会发生什么。