django-compressor-toolkit icon indicating copy to clipboard operation
django-compressor-toolkit copied to clipboard

Windows Support / export FilterError

Open FSE-DEV opened this issue 6 years ago • 5 comments

In Windows 10 environment a FilterError(err) in raised: "compressor.exception.FilterError: 'export' is not recognized".

Regarding the issue and answer here: https://stackoverflow.com/questions/55029689/use-django-compressor-es6compiler-under-windows - is Windows supported at all? If so, what cofigurations / adjustments are missing?

Thank you.

FSE-DEV avatar Apr 23 '19 13:04 FSE-DEV

Hi, I need to know if this issue will be solved, I have the same problem with the es6compiles in windows.

fermartsdc avatar Mar 10 '20 20:03 fermartsdc

same here

datablackhole avatar Jun 11 '20 20:06 datablackhole

Sorry, it's been awhile since I visited my project last time. Too much work to do on my job.

is Windows supported at all?

I have designed it to work on any platform where the underlying Node libraries work (I mean node-sass, less, etc).

But I have tested it only on Linux / macOS :)

Indeed, the problem is in the COMPRESS_ES6_COMPILER_CMD setting - its default value is for UNIX / Linux systems:

COMPRESS_ES6_COMPILER_CMD = 'export NODE_PATH="{paths}" && '
        '{browserify_bin} "{infile}" -o "{outfile}" '
        '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]'

I'm not very familiar with Windows CMD way of setting the NODE_PATH env variable right in the command line.

If you will figure it out - just set your custom Django setting:

# settings.py
COMPRESS_ES6_COMPILER_CMD = '<set the NODE_PATH env var to {paths} somehow and call> '
        '{browserify_bin} "{infile}" -o "{outfile}" '
        '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]'

If it's not possible through the CMD then it should be possible from Python:

os.environ["NODE_PATH"] = ...

But this would require a pull-request to this project.

And I'm really sorry but I'm still very busy at my main job, so I appreciate your help with the pull-request ;)

kottenator avatar Jun 11 '20 21:06 kottenator

I am trying to get this to work on windows.

This is as close as i got

settings.py

COMPRESS_ES6_COMPILER_CMD = '$env:NODE_PATH="{paths}" && {browserify_bin} "{infile}" -o "{outfile}" -t [ "{node_modules}/babelify" --presets ["{node_modules}/@babel/preset-env"] ]'
(untitledgame) PS C:\Projects\untitledgame> python manage.py compress
CommandError: An error occurred during rendering game\index.html: The filename, directory name, or volume label syntax is incorrect.
Compressing...

game\index.html

    {% compress js %}
		{% include "game/parts/scripts_libs.html" %}
	{% endcompress %}

    {% compress js %}
        {% include "game/parts/scripts_game.html" %}
        <script src="{{ STATIC_URL }}custom/js/main-common.js" type="module"></script>
        <script src="{{ STATIC_URL }}custom/js/main-game.js" type="module"></script>
    {% endcompress %}

I have verified browserify and babel actually works by running a command directly. This command works:

.\node_modules\.bin\browserify ".\static\custom\js\main-game.js" -o bundle.js -t [ "./node_modules/babelify" --presets ["./node_modules/@babel/preset-env"] ]

Andrioden avatar May 18 '23 19:05 Andrioden

if os.name == 'nt':
    COMPRESS_ES6_COMPILER_CMD = 'set NODE_PATH="{paths}" && {browserify_bin} "{infile}" -o "{outfile}" -t [ "{node_modules}\\babelify" --presets="{node_modules}\\babel-preset-es2015"]'
    COMPRESS_BROWSERIFY_BIN = 'node_modules\\.bin\\browserify'

This gets past an initial error, however ended up with a EPERM rename error, which seems to be related to the TemporaryNamedFile, using an absolute output file path avoids this, however Django can still not properly run the code

Miitto avatar Jun 10 '23 20:06 Miitto