title: Using Nunjucks in an Express App
body: <p>I have an Node app that includes Express. Up to this point, I've been using Swig as my view engine. I configured this view engine like this:</p>
  
  <pre><code>app.engine('html', swig.renderFile);
  app.set('views', path.join(__dirname, '../views'));
  app.set('view engine', 'html');    
  </code></pre>
  
  <p>This approach has worked for me. But, since Swig has been deprecated, I'm trying to move to Nunjucks. In an attempt to do this, I've done the following:</p>
  
  <pre><code>nunjucks.configure('views', {
      autoescape: true,
      cache: false,
      express: app        
  });
  
  app.engine('html', nunjucks.render);
  app.set('views', path.join(__dirname, '../views'));
  app.set('view engine', 'html');    
  </code></pre>
  
  <p>This doesn't work. I get a runtime error, but I can't tell what error is actually thrown. In an attempt to load the most basic view, I'm trying to load the following HTML page:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;Hello&lt;/h1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is intentionally a really basic HTML view that does NOT use any templating. I just want to be able to load an HTML view with nunjucks set as the view engine. Even with this, I still get an error.</p>
  
  <p>I can see that <a href="https://mozilla.github.io/nunjucks/api.html" rel="nofollow">render function</a>, has a callback. It looks like the callback has an error object I could look at. But, I don't know how to actually use that callback within the line <code>app.engine('html', nunjucks.render);</code>.</p>
  
  <p>Any insights would be much appreciated</p>