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.

[icons-v5] Cannot use import statement outside a module

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

After importing any icon from @materila-ui/icons@v5-alpha.13 I am getting the below error:

/home/hello/Documents/code/hrms/node_modules/@material-ui/icons/ArrowBackTwoTone.js:1
import * as React from 'react';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:931:16)
    at Module._compile (internal/modules/cjs/loader.js:979:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.ygQx (/home/hello/Documents/code/hrms/packages/client/.next/server/pages/d/leaves/apply.js:1408:18)
    at __webpack_require__ (/home/hello/Documents/code/hrms/packages/client/.next/server/pages/d/leaves/apply.js:29:31)
    at Object.OErO (/home/hello/Documents/code/hrms/packages/client/.next/server/pages/d/leaves/apply.js:895:93) {
  type: 'SyntaxError'
}

This issue is only comming from icons, core is working fine.

Steps to Reproduce 🕹

I have just used the updated nextjs example and converted into typescript

https://codesandbox.io/s/nextjs-materialui-ts-wz93e

Your Environment 🌎

Tech Version
Material-UI v5-alpha.13
React 16.14.0
Browser Chromium 86
TypeScript 4.0.3
Nextjs 9.5.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
eps1loncommented, Oct 18, 2020

Interesting. I just realized that we never actually supported ES modules for path imports like @material-ui/icons/ArrowBackTwoTone. Will investigate first thing tomorrow.

1reaction
dhruv9499commented, Dec 19, 2021

So which syntax we should use now onwards?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[icons-v5] Cannot use import statement outside a module
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
Material UI: cannot use import statement outside a module
If I start digging (not much though) it appears the error comes from a dependency from node_modules, it being from @mui/material and being ......
Read more >
Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
Read more >
Cannot use import statement outside a module in JavaScript
The "SyntaxError: Cannot use import statement outside a module" error is thrown when the JavaScript interpreter encounters an import statement ...
Read more >
How to fix 'Uncaught SyntaxError: Cannot use import ...
This error arises when we try to use import inside of a project which is not set up for modules - so let's...
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