whitespy / django-node-assets Goto Github PK
View Code? Open in Web Editor NEWThe Django application allows install and serve assets via Node.js package manager infrastructure.
License: MIT License
The Django application allows install and serve assets via Node.js package manager infrastructure.
License: MIT License
I am trying to run this on Windows 10 and receiving the following error: OSError: symbolic link privilege not held
. Is there a way to accomplish the same thing without using symlinks for Windows users?
The error is caused by line 16 of npminstall.py.
adding this module inside STATICFILES_FINDERS makes that collectstatic procedure of django copies also all sources to STATIC_ROOT dir.
As the title indicate, static collection also installs devDepdencies, this bloats the static folder immensely.
My suggestion is that it by default dont do this, i believe you need to do something like npm install --omit=dev
(ref)
package.json
"dependencies": {
"jquery": "^3.7.0"
},
"devDependencies": {
"@jest/globals": "^29.3.1",
"@types/jquery": "^3.5.16",
"@types/jquery.slimscroll": "^1.3.31",
"@types/jqueryui": "^1.12.16",
"@types/kineticjs": "^0.0.29",
"eslint": "^8.30.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-n": "^15.6.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-simple-import-sort": "^8.0.0",
"jest": "^29.3.1",
"jsdom": "^20.0.3",
"typescript": "^4.9.4"
},
Hi! Having to manage your executable directory across environments is going to be a bit painful.
I have to configure locally
NODE_PACKAGE_MANAGER_EXECUTABLE = "C:\\Users\\andre\\AppData\\Roaming\\npm\\npm.cmd"
and a different config is needed for CI.
My suggestion is instead to natively use the npm
command directly, and therefor require every environment to have npm installed globally. You can then remove the config all together.
Hi,
I'm trying to load my project static placed into a folder "project-static".
tree -L 3 project-static
project-static
└── tower_service_catalog
├── css
│ ├── pygments.css
│ └── tower_service_catalog.css
├── img
│ ├── admin.png
│ └── user.png
└── js
└── tower_service_catalog.js
Settings
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static/'), # retrieve from collect static command
os.path.join(BASE_DIR, "project-static/"), # project statics
]
if not DEBUG:
# useless during development, it's only required for deployment
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# TO be set when prod
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
# https://github.com/whitespy/django-node-assets
STATICFILES_FINDERS = [
'django_node_assets.finders.NodeModulesFinder',
]
NODE_PACKAGE_JSON = os.path.join(BASE_DIR, 'package.json')
NODE_MODULES_ROOT = os.path.join(BASE_DIR, 'node_modules')
Wrong config?
Many thanks for your support !
I was trying to run the npminstall
command to install my packages. Everytime I did the response was always the basic npm output when you just type "npm" and press enter. Nothing was installed.
npm <command>
Usage:
npm install install all the dependencies in your project
npm install <foo> add the <foo> dependency to your project
npm test run this project's tests
npm run <foo> run the script named <foo>
npm <command> -h quick help on <command>
npm -l display usage info for all commands
npm help <term> search for help on <term>
npm help npm more involved overview
I was intrigued by that so I checked the code from the command (the npminstall.py
file) and did a little research at the documentation of the subprocess
package, used to issue the npm install
command.
I finally got the script working by removing the executable
argument and moving its information to args
, like so:
with Popen(
args=[
'{} install'.format(getattr(settings, 'NODE_PACKAGE_MANAGER_EXECUTABLE', '/usr/bin/npm')),
'--no-package-lock',
'--prefix={}'.format(node_package_context.package_dir)
],
#executable=getattr(settings, 'NODE_PACKAGE_MANAGER_EXECUTABLE', '/usr/bin/npm'),
shell=True,
stdout=PIPE,
stderr=STDOUT,
encoding='utf-8',
) as p:
I'm using Python 3.8 and Django 2.1.5 on Ubuntu 20.04. I run my Django app through a virtual environment.
Is there any hope for a new version fixing this?
Thank you.
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.