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

SyntaxError: Cannot use import statement outside a module #196

Open
PhilippMeissner opened this issue Mar 4, 2022 · 0 comments
Open

SyntaxError: Cannot use import statement outside a module #196

PhilippMeissner opened this issue Mar 4, 2022 · 0 comments

Comments

@PhilippMeissner
Copy link

PhilippMeissner commented Mar 4, 2022

I'm submitting a...

[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request

Current behavior

When running our tests with jest we receive the error SyntaxError: Cannot use import statement outside a module

C:\path-to-project\node_modules\ngx-permissions\fesm2015\ngx-permissions.mjs:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import * as i0 from '@angular/core';
^^^^^^
SyntaxError: Cannot use import statement outside a module

Expected behavior

The import should just work as is.

Basically just create a new angular project with the given version below, add jest and jest-preset-angular. Additionally add and import the NgxPermissionsModule and run the tests.

Environment

Angular version: 12.2.3
ngx-permissions version: 13.0.1
jest version: 27.5.1
jest-preset-angular: 11.1.1
Node 12.16.3

To be perfectly honest I am not sure if this is a concern you can address or if it is something we need to change on our side.
I tried adjusting the jest.config by adding mjs into moduleFileExtensions along with node_modules/(?!ngx-permissions) to transformIgnorePatterns definition.

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

1 participant