How do I point to Node in a dockerized Django project using django-pipeline?

135 Views Asked by At

I'm trying to add django-pipeline to a dockerized Django 3.1 project. However, when I run collectstatic I receive the following error:

pipeline.exceptions.CompressorError: b'/usr/bin/env: \xe2\x80\x98node\xe2\x80\x99:
No such file or directory\n'

My settings.py file includes:

PIPELINE = {
    'CSS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
    'COMPILERS': ('pipeline.compilers.sass.SASSCompiler',),
    'YUGLIFY_BINARY': str(BASE_DIR.joinpath('node_modules/.bin', 'yuglify')),
    'SASS_BINARY': str(BASE_DIR.joinpath('node_modules/.bin', 'sass')),
    'STYLESHEETS': {
        'twirlmate': {
            'source_filenames': (
              'pages/scss/styles.css',
            ),
            'output_filename': 'css/styles.css',
        },
    },
}

And my package.json includes:

{
  ...,
  "dependencies": {
    "sass": "^1.32.5",
    "yuglify": "^2.0.0"
  }
}

I have other local Django projects that use pipeline, but not Docker, and they work fine, so I'm wondering if it has to do with Node not being installed in the container? Any thoughts/help is appreciated.

1

There are 1 best solutions below

0
On

[SOLVED]

It turns out I was missing some commands in my Dockerfile to install nodejs:

# Dockerfile

...
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs build-essential

# Set working directory and install npm dependencies for pipeline
WORKDIR /code
RUN npm -g install sass
RUN npm -g install yuglify

collectstatic now works as expected.