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.

Can no longer import micromustache v6 using ECMAScript Modules

See original GitHub issue

Prior to v6, you could use ECMAScript Modules with Node and this package.

For some reason, there isn’t the export for render in the current build. I am using this package inside a bigger project and this is the only time I’ve come across an error with a Node package.

The code I am trying to run:

import {render} from 'micromustache';
console.log("Hello, world!");

The result when running with node --es-module-specifier-resolution=node --experimental-modules index.mjs:

import {render} from 'micromustache';
        ^^^^^^
SyntaxError: The requested module 'micromustache' does not provide an export named 'render'
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:91:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:106:20)
    at async Loader.import (internal/modules/esm/loader.js:132:24)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! micromustache-demo@1.0.0 start: `node --es-module-specifier-resolution=node --experimental-modules index.mjs`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the micromustache-demo@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Sample repro: https://github.com/gda-gp/micromustache-demo

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
userpixelcommented, Dec 15, 2019

I verified the bug. Something fishy is going on as the commonjs version of the module works:

// import {render} from 'micromustache';
const { render } = require('micromustache');
console.log("Hello, world!", render('Hi {{name}}', {name: 'Alex'}));

I also verified that using esm shows the same symptom.

A workaround is to call it like this:

import mm from 'micromustache';
const { render } = mm

I’ll investigate further and make a patch ASAP. Thanks for reporting this.

0reactions
userpixelcommented, Mar 5, 2020

@gda-gp could you verify if it’s good now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

When using ECMAScript 6 modules, cannot import a ... - GitHub
The correct way to solve this in the Closure Compiler is to have an --es6-entry-point option, which specifies the root file of your...
Read more >
ES2015 "import" not working in node v6.0.0 with with
I am using node v6.0.0 and wanted to use ES2016 (ES6). However I realized that the "import" syntax is not working. Isn't "import"...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
No require , exports , or module.exports #. In most cases, the ES module import can be used to load CommonJS modules. If...
Read more >
Announcing core Node.js support for ECMAScript modules
Node.js 13.2.0 ships support for ECMAScript modules, known for their import and export statements. This support was previously behind ...
Read more >
ES Modules and Node.js: Hard Choices - NodeSource
ES Modules syntax defined, but ECMAScript does not define a "Loader" spec for how Modules are inserted into the Mode.js runtime.
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