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.meta' outside a module #5644

Closed
1 task done
jimmed opened this issue Mar 3, 2023 · 4 comments
Closed
1 task done

SyntaxError: Cannot use 'import.meta' outside a module #5644

jimmed opened this issue Mar 3, 2023 · 4 comments

Comments

@jimmed
Copy link

jimmed commented Mar 3, 2023

What version of Remix are you using?

1.14.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Using a project based on the cloudflare-workers template:

  1. Upgrade from Remix 1.13.0 to 1.14.0
  2. Launch the app in local development mode (npm run dev)

Expected Behavior

The app boots in Miniflare as normal

Actual Behavior

On startup, Miniflare throws the following fatal errors:

[mf:err] /home/jim/src/ksoc/web-app/build/index.js:7882
    import.meta && import.meta.hot && import.meta.hot.accept("remix:manifest", async (newManifest) => {
           ^^^^

SyntaxError: Cannot use 'import.meta' outside a module
    at new Script (node:vm:100:7)
    at VMScriptRunner.runAsScript (/home/jim/src/ksoc/web-app/node_modules/@miniflare/runner-vm/src/index.ts:23:20)
    at VMScriptRunner.run (/home/jim/src/ksoc/web-app/node_modules/@miniflare/runner-vm/src/index.ts:88:12)
    at Miniflare.#reload (/home/jim/src/ksoc/web-app/node_modules/@miniflare/core/src/index.ts:775:42)
    at Miniflare.getPlugins (/home/jim/src/ksoc/web-app/node_modules/@miniflare/core/src/index.ts:1018:5)
    at createServer (/home/jim/src/ksoc/web-app/node_modules/@miniflare/http-server/src/index.ts:378:19)
    at startServer (/home/jim/src/ksoc/web-app/node_modules/@miniflare/http-server/src/index.ts:485:18)
    at main (/home/jim/src/ksoc/web-app/node_modules/miniflare/src/cli.ts:111:7)
[mf:err] Unhandled Promise Rejection: /home/jim/src/ksoc/web-app/build/index.js:7882
    import.meta && import.meta.hot && import.meta.hot.accept("remix:manifest", async (newManifest) => {
           ^^^^

SyntaxError: Cannot use 'import.meta' outside a module
    at new Script (node:vm:100:7)
    at VMScriptRunner.runAsScript (/home/jim/src/ksoc/web-app/node_modules/@miniflare/runner-vm/src/index.ts:23:20)
    at VMScriptRunner.run (/home/jim/src/ksoc/web-app/node_modules/@miniflare/runner-vm/src/index.ts:88:12)
    at Miniflare.#reload (/home/jim/src/ksoc/web-app/node_modules/@miniflare/core/src/index.ts:775:42)
    at Miniflare.getPlugins (/home/jim/src/ksoc/web-app/node_modules/@miniflare/core/src/index.ts:1018:5)
    at createServer (/home/jim/src/ksoc/web-app/node_modules/@miniflare/http-server/src/index.ts:378:19)
    at startServer (/home/jim/src/ksoc/web-app/node_modules/@miniflare/http-server/src/index.ts:485:18)
    at main (/home/jim/src/ksoc/web-app/node_modules/miniflare/src/cli.ts:111:7)
@jimmed
Copy link
Author

jimmed commented Mar 15, 2023

This issue persists in 1.14.1

@m4rvr
Copy link

m4rvr commented Mar 16, 2023

Happens for me too but only when using
import { useDehydratedState } from 'use-dehydrated-state'
in the root.tsx

When I put the same code from the package in a local file e.g. app/use-dehydrated-state.ts and import from there, it magically works. 🤔 I think this is because the code of the package is in cjs format and not esm compatible.

@aerojeyenth
Copy link

I encountered the same issue when trying to use @clerk/remix package in official cloudflare template from create-remix.

This happened when I tried to follow the official documents at https://clerk.com/docs/quickstarts/get-started-with-remix

And the error occurs at 2nd step as follows:

image

And also this looks like a known issue #5259 (comment)

@jimmed
Copy link
Author

jimmed commented Apr 3, 2023

This seems to be fixed as of @remix-run/* v1.15.0

@jimmed jimmed closed this as completed Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants