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

Getting Error while generating extracts- Ng Version -14.0.1 #261

Open
rabbi2211 opened this issue Jul 28, 2022 · 5 comments
Open

Getting Error while generating extracts- Ng Version -14.0.1 #261

rabbi2211 opened this issue Jul 28, 2022 · 5 comments

Comments

@rabbi2211
Copy link

[email protected] i18n:extract
ngx-translate-extract --input ./src --output ./src/assets/i18n/{en,da,de,fi,nb,nl,sv}.json --clean --format json

node:internal/modules/cjs/loader:979
throw new ERR_REQUIRE_ESM(filename, true);
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/ravikumar/ng-code/ng-ver/node_modules/@angular/compiler/fesm2015/compiler.mjs not supported.
Instead change the require of /Users/ravikumar/ng-code/ng-ver/node_modules/@angular/compiler/fesm2015/compiler.mjs to a dynamic import() which is available in all CommonJS modules.
at Object. (/Users/ravikumar/ng-code/ng-ver/node_modules/@biesbjerg/ngx-translate-extract/dist/parsers/pipe.parser.js:3:20)
at Object. (/Users/ravikumar/ng-code/ng-ver/node_modules/@biesbjerg/ngx-translate-extract/dist/cli/cli.js:6:23)
at Object. (/Users/ravikumar/ng-code/ng-ver/node_modules/@biesbjerg/ngx-translate-extract/bin/cli.js:3:1) {

@rabbi2211
Copy link
Author

Package Version

@angular-devkit/architect 0.1401.0
@angular-devkit/build-angular 14.1.0
@angular-devkit/core 14.1.0
@angular-devkit/schematics 14.1.0
@schematics/angular 14.1.0
rxjs 7.5.6
typescript 4.7.4

@doublemcz
Copy link

doublemcz commented Aug 10, 2022

Hi, I am getting similar error even with Angular 13. After upgrade to Ng 14 it looks a little bit different but with the same source of error. CommonJS vs ES modules.

npm run i18n:extract

[email protected] i18n:extract
ngx-translate-extract --input ./src --output ./src/assets/i18n/cs.json --format json --format-indentation " "

node:internal/modules/cjs/loader:979
throw new ERR_REQUIRE_ESM(filename, true);
^

Error [ERR_REQUIRE_ESM]: require() of ES Module \app\node_modules@angular\compiler\fesm2015\compiler.mjs not supported.
Instead change the require of \app\node_modules@angular\compiler\fesm2015\compiler.mjs to a dynamic import() which is available in all CommonJS
modules.
at Object. (\app\node_modules@biesbjerg\ngx-translate-extract\dist\parsers\pipe.parser.js:3:20)
at Object. (\app\node_modules@biesbjerg\ngx-translate-extract\dist\cli\cli.js:6:23)
at Object. (\app\webapp\node_modules@biesbjerg\ngx-translate-extract\bin\cli.js:3:1) {
code: 'ERR_REQUIRE_ESM'
}

@Dylight2810
Copy link

Dylight2810 commented Aug 17, 2022

Hi Kim Biesbjerg & teams ,
I have the same problem with Angular 14.
"@angular-devkit/build-angular": "^14.1.2"
"@angular/cli": "^14.1.2"
"@angular/compiler-cli": "^14.1.2"

internal/modules/cjs/loader.js:926
throw new ERR_REQUIRE_ESM(filename);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\BMG\accounting-frontend-v2\node_modules@angular\compiler\fesm2015\compiler.mjs
at Module.load (internal/modules/cjs/loader.js:926:11)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (C:\BMG\accounting-frontend-v2\node_modules@biesbjerg\ngx-translate-extract\dist\parsers\pipe.parser.js:3:20)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'ERR_REQUIRE_ESM'
}

Thanks for your help!

@kapsiR
Copy link

kapsiR commented Oct 5, 2022

This is a duplicate of #246, there is an ongoing discussion about forking the project to have it actively maintained again, since @biesbjerg didn't update it for quite some time. (and for the record, it's 💯 his choice to do so!)

@michaelbromley
Copy link

Maintained fork: https://github.com/vendure-ecommerce/ngx-translate-extract

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

5 participants