django_vite: TypeError: expected str, bytes or os.PathLike object, not NoneType

I started a fresh Django 5.0.4 project and also did pip install django-vite

INSTALLED_APPS = [
    'django_vite',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # 'django_vite', # Tried here too instead
]

When I run the server I get TypeError: expected str, bytes or os.PathLike object, not NoneType

(Nothing else has been done to the project)

interesting, could you drop a screenshot/trace for what’s raising this?

Recreated this on my macOS Ventura having python 3.11 (the first post was from my Windows 11 laptop with python 3.10). Nothing else done except installed django_vite.
Same error(s).

(env) anjanesh-m2@Anjaneshs-MacBook-Air vite_example % pip install django-vite
Collecting django-vite
  Downloading django_vite-3.0.4-py3-none-any.whl.metadata (12 kB)
Requirement already satisfied: Django>=3.2 in /Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages (from django-vite) (5.0.4)
Requirement already satisfied: asgiref<4,>=3.7.0 in /Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages (from Django>=3.2->django-vite) (3.8.1)
Requirement already satisfied: sqlparse>=0.3.1 in /Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages (from Django>=3.2->django-vite) (0.5.0)
Downloading django_vite-3.0.4-py3-none-any.whl (18 kB)
Installing collected packages: django-vite
Successfully installed django-vite-3.0.4
(env) anjanesh-m2@Anjaneshs-MacBook-Air vite_example % code .
(env) anjanesh-m2@Anjaneshs-MacBook-Air vite_example % python3 manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
    autoreload.raise_last_exception()
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/core/management/__init__.py", line 394, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django/apps/registry.py", line 124, in populate
    app_config.ready()
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django_vite/apps.py", line 14, in ready
    DjangoViteAssetLoader.instance()
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django_vite/core/asset_loader.py", line 667, in instance
    cls._apply_default_fallback()
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django_vite/core/asset_loader.py", line 751, in _apply_default_fallback
    cls._instance._apps[DEFAULT_APP_NAME] = DjangoViteAppClient(default_config)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django_vite/core/asset_loader.py", line 229, in __init__
    self.manifest = ManifestClient(config, app_name)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django_vite/core/asset_loader.py", line 84, in __init__
    self.manifest_path = self._clean_manifest_path()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/anjanesh-m2/Dropbox/workspace/django/vite/env/lib/python3.11/site-packages/django_vite/core/asset_loader.py", line 111, in _clean_manifest_path
    Path(settings.STATIC_ROOT)
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 871, in __new__
    self = cls._from_parts(args)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 509, in _from_parts
    drv, root, parts = self._parse_args(args)
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py", line 493, in _parse_args
    a = os.fspath(a)
        ^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

I believe projects created with $ django-admin startproject don’t have a static folder setup by default…

can you make sure that’s set up correctly?

this seems to be using the STATIC_ROOT from you settings Path(settings.STATIC_ROOT), but is receiving a None instead

Ah…yes after I gave STATIC_ROOT = os.path.join(BASE_DIR, "static") in settings.py file its all good.

1 Like