Unable to run collectstatic , "references a file which could not be found: js/canvas-to-blob.min.js.map"

1k Views Asked by At

I'm trying to deploy a django react application on heroku , which uses whitenoise to handle staticfiles and cloudinary to handle media files , but when i try to run python manage.py collectstatic it returns an error 'js\canvas-to-blob.min.js' references a file whic could not be found , so i used the find static command to find the static file and discovered it was in the virtualenv folder (venv\Lib\site-packages\cloudinary\static\js\load-image.all.min.js ) and it belongs to cloudinary , when i comment out all its content , collectstatic works fine , pls is there any way to fix the error .

#installed apps
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    # 'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
    'cloudinary_storage',
    'cloudinary',
    'rest_framework',
    'corsheaders',
    'django_summernote',
    'blog.apps.BlogConfig'
]

#cloudinary storage settings
CLOUDINARY_STORAGE = {
    'CLOUD_NAME': env('CLOUD_NAME'),
    'API_KEY': env('API_KEY'),
    'API_SECRET': env('API_SECRET'),
    'STATICFILES_MANIFEST_ROOT': BASE_DIR/'static'
}
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
2

There are 2 best solutions below

0
Bipul singh kashyap On

This is not the real problem that cloudinary\static\js\load-image.all.min.js is in virtualenv. The problem is the cloudinary package apparently doesn't ship the .map file cloudinary\static\js\load-image.all.min.js.map.

Django 4 changed file discovery to also find sourcemap files, see e.g. https://code.djangoproject.com/ticket/33353

For now, you can use Django==3.2.13 and wait for cloudinary updates.

0
kamartem On

As a quick and efficient workaround you can simply add empty "canvas-to-blob.min.js.map" near "canvas-to-blob.min.js" file.