Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export 'render' (imported as 'render') was not found in 'mustache' (possible exports: default) #797

Open
cre8 opened this issue Apr 12, 2022 · 13 comments

Comments

@cre8
Copy link

cre8 commented Apr 12, 2022

I got the error when using it in a library in my angular application.

Error appeared in version 4.2.0, but not after downgrading to 4.1.0

OS: Linux

@phillipj
Copy link
Collaborator

Could you share how you're downloading & using mustache.js? Any building involved or downloading directly from a CDN?

E.g. I would not expect the same to happen if you used the simplest alternative from the README:

https://unpkg.com/mustache@latest

@cre8
Copy link
Author

cre8 commented May 11, 2022

I used it via npm without any more configuration like in the angular.json file.

A dif between the two versions should give more insights, will do it the next days and report the findings.

@JohnnyDevNull
Copy link

JohnnyDevNull commented Jun 23, 2022

I have the same problem with a Angular 12 nx monorepo.
I've installed via npm install mustache@latest --save-exact and npm install @types/mustache@latest --save-exact.
I'am upgrading from Version 3.1.0 to 4.2.0 and now i'am getting lots of

Error: export 'render' (imported as 'render') was not found in 'mustache' (possible exports: default)

Our imports looks like:

import * as mustache from 'mustache';

A downgrade to 4.1.0 works fine. So i have to stay there for now.

@JohnnyDevNull
Copy link

Push: Error is still relevant. Can't upgrade mustache to Version 4.2.0 in the Angular 14 and NX Upgrade process.

@jukkahyv
Copy link

jukkahyv commented Nov 3, 2022

Probably same root cause as #786 ?

@JohnnyDevNull
Copy link

Push: Error is still relevant.

@SettingDust
Copy link

Import it like import mustache from 'mustache'. And use as mustache.render

@JohnnyDevNull
Copy link

Import it like import mustache from 'mustache'. And use as mustache.render

import mustache from 'mustache'; leads to TS1192: Module '".../node_modules/@types/mustache/index"' has no default export.

And enabling esModuleInterop with over 200 libraries in our monorepo is no option. That leads to other problems. So actually it's impossible to update.

@abdulkareemnalband
Copy link

Apply following patch

diff --git a/node_modules/@types/mustache/index.d.ts b/node_modules/@types/mustache/index.d.ts
index 709da20..34d5407 100644
--- a/node_modules/@types/mustache/index.d.ts
+++ b/node_modules/@types/mustache/index.d.ts
@@ -419,4 +419,5 @@ export interface TemplateCache {
     clear(): void;
 }
 
-export as namespace Mustache;
+declare const mustache:{render:typeof render, escape:typeof escape, clearCache:typeof clearCache, parse:typeof parse};
+export default mustache;

Import as

import whatever from 'mustache';

// use like 
whatever.render()

@JohnnyDevNull
Copy link

Push, still relevant... unable to update. Dependabot PR is still blocked.

@vicatcu
Copy link

vicatcu commented Oct 23, 2023

Downgrade to 4.1.0 works for now 👎

@JohnnyDevNull
Copy link

Still broken, staying at 4.1.0

@ppodds
Copy link

ppodds commented Jan 18, 2024

I make a new TypeScript rewrite fork for it. However, it still lacks test cases and is incompatible with some APIs. If anyone is interested in it, please feel free to contribute it.

https://github.com/ppodds/mustache.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants