Skip to content

Cannot use import statement outside a module #490

Open
@arpitdalal

Description

@arpitdalal

Describe the bug
I'm getting Cannot use import statement outside a module when building it for prod, dev just works fine. I've type: module in my package.json and here's my tsconfig

"esModuleInterop": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",

And when importing Cropper like this import Cropper from 'react-easy-crop' gives this error when using it

JSX element type 'Cropper' does not have any construct or call signatures.ts(2604)

This project did build successfully before with these exact configs but after adding react-easy-crop, it doesn't

Full error:

(node:406) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
SyntaxError: Cannot use import statement outside a module
/myapp/node_modules/react-easy-crop/index.module.js:1
import { __assign, __extends } from 'tslib';
^^^^^^
SyntaxError: Cannot use import statement outside a module

Expected behavior
It should build successfully with these configs and shouldn't throw an error when using the Cropper component

Metadata

Metadata

Assignees

No one assigned

    Labels

    PR-welcomehelp is welcomed for this issuehelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions