Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render _bundle error: TypeError: expected string or bytes-like object #352

Closed
abadger1 opened this issue Aug 26, 2023 · 8 comments
Closed

Comments

@abadger1
Copy link

  {% render_bundle 'main' 'css' %}

error seen in ./manage.py runserver

tags = utils.get_as_tags(
File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 71, in get_as_tags
bundle = _get_bundle(loader, bundle_name, extension)
File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 47, in _get_bundle
bundle = loader.get_bundle(bundle_name)
File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 116, in get_bundle
filtered_chunks = self.filter_chunks(chunks)
File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 58, in filter_chunks
ignore = any(regex.match(chunk)
File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 58, in
ignore = any(regex.match(chunk)
TypeError: expected string or bytes-like object

venv) ➜ src git:(main) ✗ node -v
v14.21.3
(venv) ➜ src git:(main) ✗ npm -v
6.14.18
(venv) ➜ src git:(main) ✗ pip list | grep webpack
django-webpack-loader 2.0.1
(venv) ➜ src git:(main) ✗

Django version 4.2.4, using settings 've.settings.development'

@abadger1
Copy link
Author

npm run build appears to run fine - lost as to how to debug further

@abadger1 abadger1 changed the title render _bunldle error: TypeError: expected string or bytes-like object render _bundle error: TypeError: expected string or bytes-like object Aug 26, 2023
@abadger1
Copy link
Author

@abadger1
Copy link
Author

image

@abadger1
Copy link
Author

Have tried to upgrade all packages to node v18.17.1 compliant - still see same issue as above

@abadger1
Copy link
Author

    tags = utils.get_as_tags(
  File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 71, in get_as_tags
    bundle = _get_bundle(loader, bundle_name, extension)
  File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 47, in _get_bundle
    bundle = loader.get_bundle(bundle_name)
  File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 116, in get_bundle
    filtered_chunks = self.filter_chunks(chunks)
  File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 58, in filter_chunks
    ignore = any(regex.match(chunk)
  File "/home/dave/skyscanner/venv/lib/python3.10/site-packages/webpack_loader/loader.py", line 58, in <genexpr>
    ignore = any(regex.match(chunk)
TypeError: expected string or bytes-like object

@AntonBox
Copy link

@abadger1 the reason is because you use previously generated output file 'webpack-stats.json'. delete it!
and probably you have wrong STATS_FILE path. I guess adding 'static' to the path will help you.

@grimmq52156
Copy link

grimmq52156 commented Oct 8, 2023

@abadger1, I just upgraded my legacy python project and encountered the exact same problem. The issue was that my package.json was using an old version of webpack-bundle-tracker, which was v0.7.0.

After upgrading my webpack-bundle-tracker to v2.0.1 (the same as django-webpack-loader) and updating my webpack.config.js according to the latest 'configuring-webpack-bundle-tracker' section in the readme, I reran the following command:

npx webpack --config webpack.config.js

Subsequently, I successfully solved the problem.

@fjsj
Copy link
Member

fjsj commented Oct 8, 2023

Thanks @AntonBox and @grimmq52156 ! I suppose this is a version-related problem, so I'm closing this.
@abadger1 if you are still facing the issues after deleting the old generated stats, let us know.

@fjsj fjsj closed this as completed Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants