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

Module parse failed: Cannot use 'import.meta' outside a module #80

Open
dillionverma opened this issue May 17, 2023 · 9 comments
Open

Comments

@dillionverma
Copy link

image
- error ./node_modules/react-tweet/node_modules/@babel/runtime/helpers/interopRequireDefault.js
Module parse failed: Cannot use 'import.meta' outside a module (39:16)
|                 // still a Refresh Boundary later.
|                 // @ts-ignore importMeta is replaced in the loader
>                 import.meta.webpackHot.accept();
|                 // This field is set when the previous version of this module was a
|                 // Refresh Boundary, letting us know we need to check for invalidation or


Getting the following error while running.

package.json:

    "eslint-config-next": "^13.4.2",
    "next": "^13.4.2",
    "next-auth": "^4.22.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-tweet": "^2.0.1",
@lfades
Copy link
Member

lfades commented Jun 26, 2023

@dillionverma Can you provide a reproduction 🙏

@lakbychance
Copy link

lakbychance commented Jul 27, 2023

@lfades Hitting the same limitation. SWC is disabled for our project because we rely on babel for a library. I tried to create a reproduction online but couldn't. This is what I was trying -> https://codesandbox.io/p/sandbox/angry-robinson-sk8mrv?file=%2Fpackage.json%3A22%2C36. Basically just added a .babelrc.js similar to our current setup so that next disables SWC on detecting it but I can see atleast the loader of the Tweet component coming. Whereas, in our local dev, we are getting the same error like so :-
Screenshot 2023-07-27 at 3 57 00 PM

We are using the latest version i.e. 13.4.12

Any clue as to what might be happening here ?

@lfades
Copy link
Member

lfades commented Jul 27, 2023

Looks like it's something with babel when used in Next.js. The package output of react-tweet does not use import.meta and all files are modules. Did you also add reac-tweet to transpilePackages? although I'm not entirely sure if that one works with babel.

@lakbychance
Copy link

Looks like it's something with babel when used in Next.js. The package output of react-tweet does not use import.meta and all files are modules. Did you also add reac-tweet to transpilePackages? although I'm not entirely sure if that one works with babel.

Yup the transpilePackages is already added to next.config.js

@jshwrnr
Copy link

jshwrnr commented Jul 31, 2023

Getting this issue as well.

@reabreu
Copy link

reabreu commented Aug 29, 2023

Hey everyone! I'm also getting this issue, does anyone have an ideia why this is happening?

@dillionverma
Copy link
Author

So I resolved this for myself by using app router instead (Nextjs 13).

Not a feasible solution for everyone but just wanted to let people know

@reabreu
Copy link

reabreu commented Sep 3, 2023

Hey, thanks for the feedback!

@timbicker
Copy link

I solved the problem by adding

"resolutions": {
  "@babel/runtime": "^7.24.6"
},

to my package.json.
As explained in this issue

yangw-dev added a commit to pytorch/test-infra that referenced this issue Nov 9, 2024
Run into similar issue like this:
vercel/react-tweet#80
solved by adding
```
"resolutions": {
  "@babel/runtime": "^7.24.6"
},
```
Explained in this
[issue](vercel/next.js#35110 (comment))
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

6 participants