nuxt-modules / nuxt-modules/tailwindcss

[postcss] Cannot use 'import.meta' outside a module

Open
#1,031 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
1.9k
Forks
192
PR merge metrics
No merged PRs in 30d

Description

When I attempt to run it, it throws an error.

Error {
  stack: "[postcss] Cannot use 'import.meta' outside a module\n" +
  'at createError (D:/PuYuanhao/project/vpn_client/node_modules/h3/dist/index.mjs:71:15)\n' +
  'at D:/PuYuanhao/project/vpn_client/node_modules/@nuxt/vite-builder/dist/index.mjs:423:21)\n' +
  'at async processMessage (D:/PuYuanhao/project/vpn_client/node_modules/@nuxt/vite-builder/dist/index.mjs:405:30)',
  message: "[postcss] Cannot use 'import.meta' outside a module",
  data: {
    code: 'VITE_ERROR',
    id: '/@fs/D:/PuYuanhao/project/vpn_client/node_modules/@nuxtjs/tailwindcss/node_modules/tailwindcss/tailwind.css',
    stack: 'D:\\PuYuanhao\\project\\vpn_client\\node_modules\\@nuxtjs\\tailwindcss\\node_modules\\@nuxt\\kit\\dist\\index.mjs:2244\n' +
    '  if (!import.meta.dev) {\n' +
    '              ^^^^\n' +
    '\n' +
    "SyntaxError: Cannot use 'import.meta' outside a module\n" +
    '    at new Script (node:vm:117:7)\n' +
    '    at createScript (node:vm:269:10)\n' +
    '    at Object.runInThisContext (node:vm:317:10)\n' +
    '    at evalModule (D:\\PuYuanhao\\project\\vpn_client\\node_modules\\tailwindcss\\node_modules\\jiti\\dist\\jiti.js:1:251724)\n' +
    '    at jiti (D:\\PuYuanhao\\project\\vpn_client\\node_modules\\tailwindcss\\node_modules\\jiti\\dist\\jiti.js:1:249841)\n' +
    '    at D:\\PuYuanhao\\project\\vpn_client\\node_modules\\@nuxtjs\\tailwindcss\\dist\\config.cjs:7:13\n' +
    '    at evalModule (D:\\PuYuanhao\\project\\vpn_client\\node_modules\\tailwindcss\\node_modules\\jiti\\dist\\jiti.js:1:251913)\n' +
    '    at jiti (D:\\PuYuanhao\\project\\vpn_client\\node_modules\\tailwindcss\\node_modules\\jiti\\dist\\jiti.js:1:249841)\n' +
    '    at D:\\PuYuanhao\\project\\vpn_client\\node_modules\\@nuxtjs\\tailwindcss\\dist\\config-ctx.cjs:3:16\n' +
    '    at evalModule (D:\\PuYu'... 90 more characters,
    message: "[postcss] Cannot use 'import.meta' outside a module",
  },
  statusCode: 500,
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported error with the Nuxt and Tailwind setup, starting from the failing @nuxtjs/tailwindcss/dist/config.cjs and config-ctx.cjs entry points. Inspect how those files reach the @nuxt/kit import.meta.dev code while processing tailwind.css, then verify that the same setup runs without the import.meta module error.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, nuxtjs, tailwindcss, vite
Domain
build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.