在Windows下使用Django_compressor ES6Compiler

时间:2019-03-06 18:13:29

标签: django npm es6-modules django-compressor

我试图在Windows安装程序上运行在Linux下开发的Django应用。 该应用程序启动,但是当我进入一个页面时,该页面带有使用这样的压缩器的模板(“ index.js”导入npm软件包):

Error: <interactive>:1:0:XHRError

..我收到此错误:

{% load static %}
{% load compress %}
<html>
        ...
    <body>
      ...
      {% compress js %}
      <script type="module" src="{% static 'index.js' %}"></script>
      {% endcompress %}
    </body>
</html>
  

compressor.exception.FilterError:无法将'export'识别为   内部或外部命令

我的设置如下:

Traceback (most recent call last):
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\neuz8t\Downloads\cs_viewer_server\cs_viewer\views.py", line 19, in index
    return render(request,'cs_viewer/index.html',{'graph_elements':tmp_graph_elements_json})
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\shortcuts.py", line 36, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\backends\django.py", line 61, in render
    return self.template.render(context)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\base.py", line 171, in render
    return self._render(context)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\base.py", line 163, in _render
    return self.nodelist.render(context)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\base.py", line 937, in render
    bit = node.render_annotated(context)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\django\template\base.py", line 904, in render_annotated
    return self.render(context)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\templatetags\compress.py", line 131, in render
    return self.render_compressed(context, self.kind, self.mode, forced=forced)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\templatetags\compress.py", line 107, in render_compressed
    rendered_output = compressor.output(mode, forced=forced)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\js.py", line 50, in output
    ret.append(subnode.output(*args, **kwargs))
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\js.py", line 52, in output
    return super(JsCompressor, self).output(*args, **kwargs)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\base.py", line 295, in output
    output = '\n'.join(self.filter_input(forced))
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\js.py", line 60, in filter_input
    for hunk in self.hunks(forced):
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\base.py", line 205, in hunks
    precompiled, value = self.precompile(value, **options)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\base.py", line 276, in precompile
    return True, filter.input(**kwargs)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor_toolkit\precompilers.py", line 53, in input
    return super(BaseCompiler, self).input(**kwargs)
  File "C:\Users\neuz8t\AppData\Local\Programs\Python\Python37\lib\site-packages\compressor\filters\base.py", line 196, in input
    raise FilterError(err)
compressor.exception.FilterError: 'export' is not recognized as an internal or external command

我尝试了不同的方法,包括重新安装所有依赖项,重新安装所有npm软件包..到目前为止没有任何作用。

1 个答案:

答案 0 :(得分:1)

您似乎正在使用ES6Compiler from compressor_toolkit

一个is using the export command,仅在Linux上可用。您需要要求Compressor_toolkit项目添加Windows支持,或者自己构建并创建PR,或者使用linux:)