I'm trying to build Django backend based application on Docker using PyCharm with NPM and slickgrid.
When in some .js file trying to import slickgrid:
import { SlickGrid, SlickDataView } from 'slickgrid';
I'm getting Django error:
FilterError at /todo/ Error: Can't walk dependency graph: Cannot find module 'slickgrid' from '/opt/project/eTools/todo/static/todo/js/main.js'
For dealing with Django static assets I use: django-compressor django-compressor-toolkit
In Dockerfile I have something like:
`
Set work directory
WORKDIR /code (...) RUN apt-get install -y nodejs npm (...) #Slickgrid RUN npm install -g browserify babelify@8 babel-core babel-preset-env babel-cli babel-preset-es2015 RUN npm install -g slickgrid (...)
Copy the Django project
COPY ./eTools/ /code/ `
It looks like npm used indirectly by Django does not see 'slickgrid'.
In bash for Docker I see following: a) in location where app was copied in last step of Dockerfile (/code/ location) npm has slickgrid: root@f7401a6daac5:/code# npm list slickgrid code@ /code └── [email protected] b) but for unknown reason (for me at least ;)) npm seems to be called from location from exception ('/opt/project/'). checked in docker bash and there is no 'slickgrid':
root@f7401a6daac5:/opt/project# npm list slickgrid [email protected] /opt/project └── (empty)
Could you please advice how I can fix this issue? And why code is called from another location than /code? Is this related to PyCharm?
Part of Django settings related to compress and static:
`STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'eTools', 'static'),
os.path.join(BASE_DIR, 'todo', 'static'),
os.path.join(BASE_DIR, 'clients', 'static'),
'node_modules', os.path.join(BASE_DIR, 'node_modules/'),
#os.path.join(BASE_DIR, 'static', 'js'), #Add global js directory
]
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
)
COMPRESS_CSS_FILTERS = [
'compressor.filters.css_default.CssAbsoluteFilter',
'compressor.filters.cssmin.CSSMinFilter',
'compressor.filters.template.TemplateFilter',
BASE_DIR / 'static',
]
COMPRESS_JS_FILTERS = [
'compressor.filters.jsmin.JSMinFilter',
]
COMPRESS_PRECOMPILERS = (
('module', 'compressor_toolkit.precompilers.ES6Compiler'),
('css', 'compressor_toolkit.precompilers.SCSSCompiler'),
)
COMPRESS_ENABLED = True
COMPRESS_LOCAL_NPM_INSTALL = False
COMPRESS_NODE_MODULES = '/usr/local/lib/node_modules'`
Thanks!
I tried to follow multiple tutorials and maybe mixed some settings?