在docker nodejs中未安装

时间:2019-10-13 12:25:12

标签: node.js docker

在docker中安装laravel 5.7应用程序,我需要安装npm / nodejs,为此在我的web / Dockerfile.yml中,我为node添加了行:

FROM php:7.2-apache

RUN apt-get update && \
    apt-get install -y \
    python \
    libfreetype6-dev \
    libwebp-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    nano \
    git-core \
    curl \
    build-essential \
    openssl \
    libssl-dev \
    libgmp-dev \
    libldap2-dev \
    netcat \
    sqlite3 \
    libsqlite3-dev \
     && git clone https://github.com/nodejs/node.git \
     && cd node \
     && ./configure \
     && make \
     && make install

  RUN  docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/  --with-jpeg-dir=/usr/include/


  RUN  docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite

COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf

运行

docker-compose up -d --build

命令输出很长,一切运行正常

但是进入shell时,我发现我没有nodejs,正如我期望的那样,通过安装node.git

/var/www/html# npm -v
6.11.3
/var/www/html# nodejs -v
bash: nodejs: command not found
/var/www/html# composer install
bash: composer: command not found

怎么了?

1 个答案:

答案 0 :(得分:2)

使用node -v代替nodejs

  -v, --version               print Node.js version

或者您可以使用

探索更多选项
node --help

在构建期间

RUN node --version

测试节点版本

  

要查看是否已安装Node,请在终端中键入node -v。这应该   打印版本号,这样您将看到类似v<version>的内容。