markfinger / django-node Goto Github PK
View Code? Open in Web Editor NEW[UNMAINTAINED] Django/Node integration
License: MIT License
[UNMAINTAINED] Django/Node integration
License: MIT License
If npm fails half-way, it'll often break node_modules in a way that is only repairable by removing the directory and running npm install again.
Maybe:
./manage.py npm_remove_node_modules
delete node_modules
directory in every app's root./manage.py npm_install
invoke npm install on every app with a package.json
file./manage.py npm_repair
perform both of the aboveRe: markfinger/python-react#20
Maybe put it behind a setting which is checked in utils.resolve_dependencies
and rely on child packages to use that entry point?
It would be nice to let the users choose a different location for node_modules directory instead of node_modules in the source directory. Some times, we install packages globally instead of a virtualenv (like when in docker) so normal users cannot write to /usr/local/lib/python/...
Also, some times, we might already have a node_modules directory specified for other npm modules used with the product with proper PATHs set.
I'm hesitant to do anything for dev - as you want to pick up on errors - but it's pretty undesirable for a prod server to go down if, for example, a parser freaks out.
Dependencies should be resolved on a per-path basis and npm install should only be invoked if it has not already been called on that directory.
TypeError: Cannot read property 'onReady' of undefined
Should be
TypeError: Cannot read property 'onReady' of undefined
Currently they only throw ServerConfigMissingService
if they are not available on the server. They should throw an error if they are missing from SERVICES
Re #10
I try using this module on python 3.4, but i receive this error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/home/styleex/ferrario/env/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1448, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django_react/__init__.py", line 1, in <module>
from .components import ReactComponent
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django_react/components.py", line 10, in <module>
from .render import render_component
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django_react/render.py", line 4, in <module>
from django_node import npm, node
File "/home/styleex/ferrario/env/lib/python3.4/site-packages/django_node/npm.py", line 2, in <module>
import settings
ImportError: No module named 'settings'
We currently have a setup where we have multiple developers some are on Linux and others are on Windows.
On Linux django_node works perfectly, but on Windows it fails.
We get the following trace:
"C:\Program Files (x86)\JetBrains\PyCharm 4.0.6\bin\runnerw.exe" C:\Python34\python.exe C:/Users/Frank/Dropbox/PycharmProjects/prototype/manage.py runserver 8000
Traceback (most recent call last):
File "C:/Users/Frank/Dropbox/PycharmProjects/prototype/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "C:\Python34\lib\site-packages\django\core\management__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Python34\lib\site-packages\django\core\management__init__.py", line 312, in execute
django.setup()
File "C:\Python34\lib\site-packages\django__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python34\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models(all_models)
File "C:\Python34\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python34\lib\importlib__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2254, in _gcd_import
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1471, in exec_module
File "", line 321, in _call_with_frames_removed
File "C:\Python34\lib\site-packages\django_node\models.py", line 5, in
install_configured_package_dependencies()
File "C:\Python34\lib\site-packages\django_node\package_dependent.py", line 19, in install_configured_package_dependencies
install_dependencies(directory)
File "C:\Python34\lib\site-packages\django_node\package_dependent.py", line 8, in install_dependencies
resolve_dependencies(path_to_run_npm_install_in=directory)
File "C:\Python34\lib\site-packages\django_node\utils.py", line 223, in resolve_dependencies
npm.install(path_to_run_npm_install_in)
File "C:\Python34\lib\site-packages\django_node\npm.py", line 37, in install
ensure_installed()
File "C:\Python34\lib\site-packages\django_node\npm.py", line 16, in ensure_installed
raise_if_dependency_missing(NPM_NAME)
File "C:\Python34\lib\site-packages\django_node\utils.py", line 121, in raise_if_dependency_missing
raise MissingDependency(error)
django_node.exceptions.MissingDependency: NPM is not installed or cannot be found at path "npm".
NPM is installed and available in the Windows path as npm --version
works.
Would be worth checking if io.js is compatible.
I believe it uses the same entry point, node
, so the only issue I can forsee would be version parsing.
It's pretty easy to leave out the trailing comma.
Or maybe just point to django-webpack or django-react's one
The blocking nature of the subprocess is pretty opaque and makes it look broken, particularly if you're not expecting the extra stage when each app installs its dependencies.
npm.install
should invoke subprocess.call
, rather than utils.run_command
.
Need to document:
django_node.node_server.NodeServer
django_node.server.server
Should have a similar API and functionality set to the npm bindings.
I can't imagine a situation where services would want access to bower_components but they're useful in projects, so a functionality similar to the PACKAGE_DEPENDENCIES setting would be good - BOWER_DEPENDENCIES or some such.
https://github.com/nvbn/django-bower exists, but you lose a lot and gain very little by abstracting away bower's API to a handful of management commands. I'm more inclined to rely on bower's CLI locally and use these bindings to simply invoke bower install
for dependency management on non-developer machines and remote servers.
I am using windows but I couldnt get django to find the npm
binary. after going through the source, settings.py
I noticed this
PATH_TO_NPM = setting_overrides.get(
'PATH_TO_NODE',
'npm'
)
shouldn't it be
PATH_TO_NPM = setting_overrides.get(
'PATH_TO_NPM',
'npm'
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.