nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
961 stars 59 forks source link

Broken build - "stdin" is not exported by unenv #269

Closed Mehdi-Hp closed 4 weeks ago

Mehdi-Hp commented 1 month ago

Not sure if it's directly from @nuxt/icon or a dependency breaking change, but build breaks as soon as you add @nuxt/icon to modules. develop works okay.

Downgrading unenv or using the nightly version didn't help.

To reproduce:

  1. pnpx nuxthub init test-app
  2. pnpx nuxi module add icon
  3. pnpm build

Logs:

[nitro 3:07:35 PM]  ERROR  RollupError: node_modules/.cache/nuxt/.nuxt/dist/server/_nuxt/prompt-BuYSwD7c.js (1:9): "stdin" is not exported by "node_modules/.pnpm/unenv@1.10.0/node_modules/unenv/runtime/node/process/index.mjs", imported by "node_modules/.cache/nuxt/.nuxt/dist/server/_nuxt/prompt-BuYSwD7c.js".

1: import { stdin, stdout } from "node:process";
            ^
2: import f from "node:readline";
3: import { WriteStream } from "node:tty";

[3:07:35 PM]  ERROR  node_modules/.cache/nuxt/.nuxt/dist/server/_nuxt/prompt-BuYSwD7c.js (1:9): "stdin" is not exported by "node_modules/.pnpm/unenv@1.10.0/node_modules/unenv/runtime/node/process/index.mjs", imported by "node_modules/.cache/nuxt/.nuxt/dist/server/_nuxt/prompt-BuYSwD7c.js".

  at getRollupError (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
  at error (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
  at Module.error (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:13971:16)
  at Module.traceVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:14419:29)
  at ModuleScope.findVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:12121:39)
  at ChildScope.findVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
  at ClassBodyScope.findVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
  at ChildScope.findVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
  at ChildScope.findVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
  at FunctionScope.findVariable (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
  at Identifier.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:6941:40)
  at AssignmentPattern.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at Property.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at ObjectPattern.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at FunctionExpression.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at MethodDefinition.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at ClassBody.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at ClassDeclaration.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at Program.bind (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at Module.bindReferences (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:13950:18)
  at Graph.sortModules (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:20201:20)
  at Graph.build (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:20105:14)
  at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
  at async node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:20751:13
  at async catchUnfinishedHookActions (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:20258:16)
  at async rollupInternal (node_modules/.pnpm/rollup@4.21.0/node_modules/rollup/dist/es/shared/node-entry.js:20746:5)
  at async _build (node_modules/.pnpm/nitropack@2.9.7_@opentelemetry+api@1.9.0_encoding@0.1.13_magicast@0.3.5_webpack-sources@3.2.3/node_modules/nitropack/dist/nitro.mjs:2633:20)
  at async node_modules/.pnpm/nuxt@3.13.2_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.14.9_encoding@0.1.1_ybhcnuqrdhnlo4pjzrhb752cba/node_modules/nuxt/dist/index.mjs:3630:5
  at async build (node_modules/.pnpm/nuxt@3.13.2_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+node@20.14.9_encoding@0.1.1_ybhcnuqrdhnlo4pjzrhb752cba/node_modules/nuxt/dist/index.mjs:5778:3)
  at async Object.run (node_modules/.pnpm/nuxi@3.13.2/node_modules/nuxi/dist/chunks/build.mjs:102:5)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.13.2/node_modules/nuxi/dist/shared/nuxi.b8b195e1.mjs:1648:16)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.13.2/node_modules/nuxi/dist/shared/nuxi.b8b195e1.mjs:1639:11)
  at async runMain$1 (node_modules/.pnpm/nuxi@3.13.2/node_modules/nuxi/dist/shared/nuxi.b8b195e1.mjs:1777:7)

arnauddoub commented 1 month ago

I have the same problem but it seems to be linked to the Cloudflare preset

Mehdi-Hp commented 1 month ago

Any suggestions on what I should downgrade for now? I tried downgrading unenv and @nuxthub/core, but no luck.

arkhaiel commented 1 month ago

Interesting. I have a project with Nuxt/Content/UI/NuxtHub, everything up-to-date. I use nuxt-icon "behind" nuxt-ui because it is used by nuxt-ui, but the module itself is not declared in the nuxt.config.ts in the root of my peoject. I've built a lot of versions of my project, where I use icons, without any problem.

2 days ago I tried to fix the problem described in #259 by installing local collections and adding an icon entry in my nuxt.config.ts with https://github.com/nuxt/icon/issues/259#issuecomment-2389235126 because I don't like the fact the icons won't load, it's definitely not a normal behaviour.

After this step, I encountered the issue described here. I spent 1-2 hours trying to understand how/why, because there was no reason to incriminate nuxt-icon (I don't build after each commit and npm run dev was running fine). The fact it's because of nuxt-icon was definitely not obvious to me since I "just installed few icon collections and added options to nuxt-icon".

Hope this will help. You can try building with nuxt-ui and without nuxt-icon in your modules, I think you will be able to build your project... looks like when nuxt-icon is behind nuxt-ui proxy, everything works fine.

My 2 cents

edit : well, nope, I just applied again everything I said before and now the build is ok

Now I'm lost 🥳

miqlangelo commented 1 month ago

I have recently encountered the same problem when the Nitro presets are set on cloudflare-pages. If I remove the Nuxthub module, I can build my project without any issues. I'm using Nuxt UI without integrating any extra @nuxt/icon.

With npm, I can build the application as usual.

It's strange that I only have this problem in new projects. I can still build old projects with Hub/UI error-free using pnpm. However, when I copy everything from those into a new application, I get the "stdin is not exported" error again.

Unfortunately, adding @nuxt/icon did not help.

node: 20.18.0 pnpm: 9.12.1 nuxt: 3.13.2

Barnabas commented 1 month ago

Sadly, adding an .npmrc file with shamefully-hoist = true seems to fix it.

Found via: https://github.com/harlan-zw/nuxt-seo/issues/218#issuecomment-2351823567

Mehdi-Hp commented 1 month ago

This just got fixed in the latest version of @nuxthub/core 🎊

antfu commented 4 weeks ago

Consider this get fixed. If this occurs again, please create a new issue with a minimal reproduction, thanks!