question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require('nunjucks') within webpack returns an empty object

See original GitHub issue

When requiring nunjucks within a webpack project, an empty object is returned instead of nunjucks.

eg.

// webpack.config.js
module.exports = {
    entry: './main.js'
};
// main.js
var nunjucks = require('nunjucks');
console.log(nunjucks); // outputs {}

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:31 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
dgbeckcommented, May 12, 2016

Gotcha. Removing chokidar seems like a solid idea!

Thanks for merging this for now, and also for your help maintain this awesome library. It is so slick in so many ways!

1reaction
davidchasecommented, Sep 10, 2015

@carljm i think it should be documented, because it also seems to be doing the same thing with browserify. Anyone coming to nunjucks for the 1st time doesn’t expect this resolution as the default just my $0.02.

to do it within browserify you need to shim it like webpack using browserify-shim transform.

adding something like this to package.json:

  "browserify": {
    "transform": [
      "browserify-shim"
    ]
  },
  "browserify-shim": {
    "nunjucks": "nunjucks"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why webpack returns an empty object when requiring its output?
In case you build a library for others to use from node_modules, you need to tell webpack that you want to support umd...
Read more >
Nunjucks API
API. The API for nunjucks covers rendering templates, adding filters and extensions, customizing template loading, and more.
Read more >
SETUP SIMPLE WEBSITE USING NODE.JS, EXPRESS ...
Let's install the required dependencies using the following commands. Install Node & npm from nodejs.org. or you can directly install it using brew ......
Read more >
How to Set Up Nunjucks with ExpressJS - DEV Community ‍ ‍
First, create an empty folder. Navigate into the folder and run the following command to initialise npm: npm init.
Read more >
email-templates - npm
Start using email-templates in your project by running `npm i ... pass an i18n configuration object as config.i18n (or an empty one as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found