[Redwood] JS_Parse_Error occurs with "./manage.py lms collectstatic"

Has the following error been reported anywhere?

Django’s collectstatic error occurs in the environment built by “tutor[full]==18.0.0”.

tutor local exec lms ./manage.py lms collectstatic --noinput

Error Content

Error: Cannot uglify2 file: /tmp/tmpmmlas1dy/js/student_account/logistration_factory.js. Skipping it. Error is:
Unexpected character '`' (line: 1276, col: 36, pos: 51283)

Error
    at new JS_Parse_Error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19710:18)
    at js_error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19718:11)
    at parse_error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19831:9)
    at Object.next_token [as input] (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20095:9)
    at next (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20195:25)
    at expect_token (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20228:20)
    at expect (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20233:36)
    at expr_list (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20736:44)
    at subscripts (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20875:30)
    at subscripts (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20852:20)
Error: Cannot uglify2 file: /tmp/tmpmmlas1dy/js/student_account/views/account_settings_factory.js. Skipping it. Error is:
Unexpected token: operator (>) (line: 22164, col: 85, pos: 1573208)

Error
    at new JS_Parse_Error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19710:18)
    at js_error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19718:11)
    at croak (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20209:9)
    at token_error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20217:9)
    at unexpected (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20223:9)
    at expr_atom (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20730:9)
    at maybe_unary (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20892:19)
    at expr_ops (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20927:24)
    at maybe_conditional (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20932:20)
    at maybe_assign (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20956:20)
Error: Cannot uglify2 file: /tmp/tmpmmlas1dy/teams/js/teams_tab_factory.js. Skipping it. Error is:
Unexpected token operator «=», expected punc «,» (line: 2915, col: 58, pos: 111996)

Error
    at new JS_Parse_Error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19710:18)
    at js_error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:19718:11)
    at croak (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20209:9)
    at token_error (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20217:9)
    at expect_token (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20230:9)
    at expect (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20233:36)
    at /openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20498:52
    at function_ (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20503:15)
    at expr_atom (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20722:24)
    at maybe_unary (/openedx/venv/lib/python3.11/site-packages/require/resources/r.js:20892:19)

This is caused django-require.
Django-require depends on RequireJS,
But RequireJS doesn’t support ES6.

$ node /openedx/venv/lib/python3.11/site-packages/require/resources/r.js -v
r.js: 2.1.22, RequireJS: 2.1.22, UglifyJS2: 2.6.1, UglifyJS: 1.3.4
$ npm install uglify-js@2.6.1
$ uglifyjs --version
uglify-js 2.6.1
$ uglifyjs cms/static/js/utils/copy_to_clipboard.js
Parse error at cms/static/js/utils/copy_to_clipboard.js:18,38
Unexpected token operator «=», expected punc «,»
Error
    at new JS_Parse_Error (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1526:18)
    at js_error (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:1534:11)
    at croak (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2025:9)
    at token_error (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2033:9)
    at expect_token (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2046:9)
    at expect (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2049:36)
    at eval (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2314:52)
    at function_ (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2319:15)
    at eval (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2160:24)
    at eval (eval at <anonymous> (/openedx/edx-platform/node_modules/uglify-js/tools/node.js:22:1), <anonymous>:2072:24)

Hi @d.yasunami, welcome to the forum!!

First, please checkout the latest version of Tutor 18.0.0 can still have bugs.
Then, you should not run the collectstatic command directly on a running container. If you are running local, then all static collection is done at image building time. If you are using a custom theme, build a new openedx image and restart your container. In dev, static collection is run automatically when you change a file in the theme.

1 Like

Hi Mr. @Andres.Aulasneo , thank you for your answer.

GitHub recommends collectstatic, but is that a mistake?

I try the command in pure environment.(no plugin and no thema)

And I found the same error in image build as well.
tutor images build openedx > image_build_result.txt 2>&1

Should I report the above as a bug?

I’ve just built successfully openedx with Tutor 18.1.3, so I don’t think there is a bug. Please share your image_build_result.txt so see if something shows up there.

1 Like

I’m sharing it on github because of the error below.

Sorry, new users can not upload attachments.

If you have the same one, please compare.

Are you doing any theming in your site? Or are you using a custom edx-platform? Where are you building your images? Is it a unix-based system? Intel or ARM? On Ubuntu, in Intel platforms it is proven to work.

Hi, Mr. @Andres.Aulasneo

As I wrote before, this is a pure environment that does not use a theme or do any customization.
I am detecting this phenomenon in an Intel WSL2 environment.

We have also confirmed that the platform functions normally.
However,the problem is that obfuscating the js is failing due to an error in ugrifyjs.

By the way, were you able to compare the build results?

The build fails, the logs are not normal. If the platform is still functioning normally, it’s because you are using the default images. If you need to build new images, I suggest you try on an Ubuntu or Mac machine. There is little experience in WSL2, and is highly probable to give problems.