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 #1366

Closed
arjangimahdi opened this issue Feb 17, 2024 · 3 comments
Closed

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

arjangimahdi opened this issue Feb 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@arjangimahdi
Copy link

Environment

Node version: 20.11.0
Nuxt version: 3.10.1
Package manager : pnpm - 8.15.3

Version

3.8.2

Reproduction

None

Description

After making contributions to this repository and adding my changes last week, I encountered an error in the development branch when pulling the latest changes. However, when I switched to the main branch, the error disappeared.

> @nuxt/ui@2.13.0 dev /Users/mahdi.arjangi/Desktop/projects/ui
> nuxi dev docs

Nuxt 3.10.1 with Nitro 2.8.1                                                                                       1:16:27 PM

 ERROR  Cannot use 'import.meta' outside a module                                                                  1:16:27 PM

  const _require = _nodemodule.createRequire.call(void 0, import.meta.url)
  ^^^^
  
  SyntaxError: Cannot use 'import.meta' outside a module
  at new Script (node:vm:99:7)
  at createScript (node:vm:255:10)
  at Object.runInThisContext (node:vm:303:10)
  at evalModule (node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:256254)
  at jiti (node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:254371)
  at src/module.ts:7:40
  at evalModule (node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:256443)
  at jiti (node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:254371)
  at docs/nuxt.config.ts:3:39
  at evalModule (node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:256443)
  at Object.jiti (node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:254371)
  at resolveConfig (node_modules/.pnpm/c12@1.6.1/node_modules/c12/dist/index.mjs:308:24)
  at loadConfig (node_modules/.pnpm/c12@1.6.1/node_modules/c12/dist/index.mjs:117:40)
  at async loadNuxtConfig (node_modules/.pnpm/@nuxt+kit@3.10.1_rollup@3.29.4/node_modules/@nuxt/kit/dist/index.mjs:2516:18)
  at async Object.run (node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/chunks/dev.mjs:172:25)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1648:16)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1639:11)
  at async runMain$1 (node_modules/.pnpm/nuxi@3.10.0/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1773:7) 

Additional context

No response

Logs

No response

@arjangimahdi arjangimahdi added the bug Something isn't working label Feb 17, 2024
@romhml
Copy link
Collaborator

romhml commented Feb 18, 2024

I experienced the same issue on the dev branch recently, I fixed it by re-cloning the repository and running:

pnpm install --frozen-lockfile
pnpm dev:prepare

Hope this helps.

Copy link
Member

I do encounter the same error sometimes and the only fix I found is to restart my mac.. Not sure what's the issue here 😬

Copy link
Member

This should have been solved by the revert of #1272 in #1404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants