skip to Main Content

I am trying to setup a laravel project in my windows setup via WSL and i am using WSL. now the issue is, when i do npm install i am getting the following error and i have tried different type of solutions but nothing is working. Any quick help would appriciable

enter image description here

please let me know if any additional detail required to solve this. i will provide the same

current version on my WSL
node – 21
npm – 10
nvm – 0.39.0

Here is the docker file also

FROM php:7.2-apache

RUN sed -i ‘s/stable/updates/stable-security/updates/’ /etc/apt/sources.list
RUN apt-get update –fix-missing

RUN mkdir -p /usr/share/man/man1
RUN mkdir -p /usr/share/pdftk

RUN apt-get update && apt-get install -y make
RUN apt-get install -y openjdk-11-jre
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y git
RUN apt-get install -y curl
RUN apt-get install -y libssl-dev
RUN apt-get install -y libmcrypt-dev
RUN apt-get install -y libgmp-dev
RUN apt-get install -y libtidy-dev
RUN apt-get install -y libpspell-dev
RUN apt-get install -y libcurl4-gnutls-dev
RUN apt-get install -y libldap2-dev
RUN apt-get install -y libc-client-dev
RUN apt-get install -y libkrb5-dev
RUN apt-get install -y librecode-dev
RUN apt-get install -y libsnmp-dev
RUN apt-get install -y libenchant-dev
RUN apt-get install -y make
RUN apt-get install -y python2.7
RUN apt-get install -y build-essential
RUN rm -r /var/lib/apt/lists/*

COPY ./pdftk/pdftk.jar /usr/share/pdftk/
COPY ./pdftk/commons-lang3.jar /usr/share/java/
COPY ./pdftk/bcprov-1.58.jar /usr/share/java/

COPY ./pdftk/pdftk /usr/bin
RUN chmod +x /usr/bin/pdftk

RUN apt-get clean

RUN docker-php-ext-configure gmp
RUN docker-php-ext-configure imap –with-kerberos –with-imap-ssl

RUN docker-php-ext-install gmp snmp soap gd enchant recode curl tidy
opcache pspell xmlrpc ldap bz2 imap dba intl xml mbstring zip pdo_mysql
gmp gd bcmath ctype json tokenizer exif mysqli calendar

RUN curl –silent –show-error https://getcomposer.org/installer |
php — –install-dir=/usr/local/bin –filename=composer

RUN pecl install imagick mongodb

RUN echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini &&
echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongodb.ini

ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN sed -ri -e ‘s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g’ /etc/apache2/sites-available/.conf
RUN sed -ri -e ‘s!/var/www/!${APACHE_DOCUMENT_ROOT}!g’ /etc/apache2/apache2.conf /etc/apache2/conf-available/
.conf

RUN a2enmod rewrite

ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 8.17.0
RUN mkdir $HOME/.nvm &&
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash &&
chmod +x $HOME/.nvm/nvm.sh &&
. $HOME/.nvm/nvm.sh &&
nvm install –latest-npm "$NODE_VERSION" &&
nvm alias default "$NODE_VERSION" &&
nvm use default &&
DEFAULT_NODE_VERSION=$(nvm version default) &&
ln -sf /root/.nvm/versions/node/$DEFAULT_NODE_VERSION/bin/node /usr/bin/nodejs &&
ln -sf /root/.nvm/versions/node/$DEFAULT_NODE_VERSION/bin/node /usr/bin/node &&
ln -sf /root/.nvm/versions/node/$DEFAULT_NODE_VERSION/bin/npm /usr/bin/npm

RUN npm install gulp -g

RUN pecl install xdebug-2.9.8
&& docker-php-ext-enable xdebug

2

Answers


  1. Chosen as BEST ANSWER

    Thank you for your responses but finally i got the solution. I was running the project inside WSL docker. I just make the container down and then make it up again and then i ran npm install and it worked.

    • sudo docker-compose down
    • sudo docker-compose up -d
    • sudo docker-compose exec your_image_name bash
    • npm install

    Then it worked. Thanks

    =======


  2. Well, the build is failing because your container doesn’t have python2. This suggests to me that you are trying to build an older version of node-sass. If there is not a good reason for that, my first suggestion is that you build at least a newer version, if not the latest.

    Then, I found that I was able to build node-sass with the following dependencies on alpine:

    • python3
    • make
    • g++

    This is accomplished on alpine with apk add --no-cache python3 make g++

    Other package managers will be different.

    Without seeing your Dockerfile, that’s about all I can give you. If you absolutely must use this version of node-sass, you will need to use an older base container that will allow you to install python2, and this will mean an older version of node as well most likely. Finally, I recommend you use yarn instead of NPM. I find it to be easier to read the error output, and friendlier in general.

    Edit:
    Here is a working Dockerfile.

    FROM node:21-alpine3.17
    RUN apk add --no-cache python3 make g++ && 
    yarn global add node-sass
    

    Of course this container is fairly useless, but it shows that the build works with these dependencies.

    My advice holds for your php version as well – unless you have a good reason to run 7.2, you should update to 8.0 (minimum non-EOL version) or 8.2.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search