Use npm library for django on runserver environment

Viewed 55

I made static folder in my root project.

in settins.py

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

Install npm library under static directory.

myproject/static$ npm -i js-cookie

then There comes the files like this

myproject/static/node_modules/js.cookie/dist/js.cookie.min.js

then run server

myproject$ python manage.py runserver

then use in template.html

However this shows the error

GET http://localhost:8000/static/node_modules/js.cookie/dist/js.cookie.min.js net::ERR_ABORTED 404 (Not Found)

I have two quesitons.

  1. Is it good practice to use npm library under django project??

  2. Maybe runserver doesn't use mypoject/static?

0 Answers
Related