title: Django (Ubuntu): What is the best way to use npm for front-end dependency management
body: <p>How I used to create my Django projects</p>
  
  <ul>
  <li><code>mkvirtualenv env1</code> - creates virtual environment env1</li>
  <li><code>pip install -r requirements.txt</code> - install some python modules</li>
  <li><code>pip install nodeenv</code> - for isolated node environments</li>
  <li><code>nodeenv -p</code> - This commands installs nodejs and adds new shell functions to our virtualenvwrapper shell functions. Directory node_modules was put inside env1 directory</li>
  <li><code>npm install -g bower</code> - Bower directory was put in node_modules inside env1.</li>
  <li><code>pip install django-bower</code> - I set <code>BOWER_COMPONENTS_ROOT = '/PROJECT_ROOT/components/'</code></li>
  <li>I set <code>BOWER_INSTALLED_APPS</code> and run <code>./manage.py bower install</code>. Packages listed in <code>BOWER_INSTALLED_APPS</code> were installed into <code>'/PROJECT_ROOT/components/bower_components'</code></li>
  <li>at the end I used <code>django-compressor</code></li>
  </ul>
  
  <p>However Bower is now apparently no longer a thing, so i need a new setup. For now I decided, that I'm gonna use only npm for front-end dependency management. So my question is, if the following setup is good enough. NOTE - I am a complete rookie regarding npm and javascript environments</p>
  
  <ul>
  <li>Create nodeenv environment inside virtualenv env1. Then in django project root I run <code>npm init</code> which creates <code>package.json</code>, and then from the same directory I run <code>npm install foundation-sites --save</code> for example. This creates node_modules in project root. Then I could use <code>django-compressor</code> with precompilers that work on node_modules directory (the one inside project root). So with this setup one node_modules directory is in env1, and the only package inside is npm (if I understand correctly, npm is installed glodally but still within virtual environment). Foundation package and its dependencies are in directory node_modules inside project root (installed locally within virtual environment).</li>
  </ul>
  
  <p>Is nodeenv even necessary for this purpose or is it better if npm is installed  globally (outside of virtual environments) and then for each project we run <code>npm init</code> and install all packages locally. I don't know if this even works.</p>