【问题标题】:How do I point to Node in a dockerized Django project using django-pipeline?如何使用 django-pipeline 在 dockerized Django 项目中指向 Node?
【发布时间】:2021-04-25 09:33:15
【问题描述】:

我正在尝试将 django-pipeline 添加到 dockerized Django 3.1 项目中。但是,当我运行 collectstatic 时,我收到以下错误:

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

我的settings.py 文件包括:

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',
        },
    },
}

我的package.json 包括:

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

我还有其他使用管道但不使用 Docker 的本地 Django 项目,它们工作正常,所以我想知道这是否与容器中未安装 Node 有关?任何想法/帮助表示赞赏。

【问题讨论】:

    标签: python node.js django docker django-pipeline


    【解决方案1】:

    [已解决]

    原来我在Dockerfile 中缺少一些命令来安装 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 现在可以正常工作了。

    【讨论】:

      猜你喜欢
      • 2018-11-06
      • 1970-01-01
      • 2019-04-23
      • 1970-01-01
      • 2020-11-18
      • 2022-01-18
      • 2016-09-28
      • 2020-02-23
      • 1970-01-01
      相关资源
      最近更新 更多