-
-
Notifications
You must be signed in to change notification settings - Fork 473
fix: Error: spawn npm ENOENT #1621
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
fix: Error: spawn npm ENOENT #1621
Conversation
🦋 Changeset detectedLatest commit: b715cd9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a changeset declaring a patch for flowbite-react and updates the CLI install command to handle Windows by appending Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant CLI as Install Command
participant H as withWindowsSupport()
participant X as execCommand()
participant OS as OS/npm
U->>CLI: run install
CLI->>H: adapt command (win32? add ".cmd")
H-->>CLI: adaptedCommand
CLI->>X: execCommand(adaptedCommand, args)
X->>OS: spawn process
OS-->>X: exit code / error
X-->>CLI: result
CLI-->>U: output
note over H,X: Changed: Windows-specific command adaptation before exec
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
.changeset/gold-actors-doubt.md (1)
5-5
: Make the changeset note explicit about the Windows scope and the actual fix.Helps release notes consumers understand what changed and why.
-fix: Error: spawn npm ENOENT +fix(cli, windows): append .cmd to package manager commands to avoid "spawn ENOENT"packages/ui/src/cli/commands/install.ts (2)
37-40
: Guard against empty command from resolveCommand for clearer failure.If resolveCommand returns undefined, you may try to spawn an empty string (or “.cmd” on Windows). Fail fast with a helpful message.
const { command = "", args } = resolveCommand(pm.agent, "add", [packageName]) ?? {}; console.log(`Installing ${packageName} using ${pm.name}...`); - await execCommand(withWindowsSupport(command), args); + if (!command) { + throw new Error(`Unable to resolve '${pm.name}' add command for ${packageName}`); + } + await execCommand(withWindowsSupport(command), args);Apply the same check in the update branch above.
3-3
: Consider centralizing Windows command resolution inside execCommand.Moving the shim into ../utils/exec-command keeps all spawn behavior consistent and avoids future call-site drift.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
bun.lock
is excluded by!**/*.lock
📒 Files selected for processing (2)
.changeset/gold-actors-doubt.md
(1 hunks)packages/ui/src/cli/commands/install.ts
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/ui/src/cli/commands/install.ts (1)
packages/ui/src/cli/utils/exec-command.ts (1)
execCommand
(12-47)
🪛 LanguageTool
.changeset/gold-actors-doubt.md
[grammar] ~5-~5: There might be a mistake here.
Context: ... patch --- fix: Error: spawn npm ENOENT
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: 🧰 Build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/ui/src/cli/commands/install.ts (1)
46-48
: Avoid potential “.cmd.cmd” duplication; keep the simple approach.Maintain the preferred simple strategy but guard against already-suffixed commands.
-function withWindowsSupport(command: string): string { - return process.platform === "win32" ? `${command}.cmd` : command; -} +function withWindowsSupport(command: string): string { + if (process.platform !== "win32") return command; + // Prevent duplicate suffix when resolveCommand already returns *.cmd + return command.toLowerCase().endsWith(".cmd") ? command : `${command}.cmd`; +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/ui/src/cli/commands/install.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: SutuSebastian
PR: themesberg/flowbite-react#1621
File: packages/ui/src/cli/commands/install.ts:46-48
Timestamp: 2025-09-01T10:44:59.759Z
Learning: In the flowbite-react CLI install command, the maintainer prefers a simple Windows support implementation that appends .cmd to all commands on win32, rather than a more defensive approach, because they know the command will only be package managers from the resolveCommand function.
📚 Learning: 2025-09-01T10:44:59.759Z
Learnt from: SutuSebastian
PR: themesberg/flowbite-react#1621
File: packages/ui/src/cli/commands/install.ts:46-48
Timestamp: 2025-09-01T10:44:59.759Z
Learning: In the flowbite-react CLI install command, the maintainer prefers a simple Windows support implementation that appends .cmd to all commands on win32, rather than a more defensive approach, because they know the command will only be package managers from the resolveCommand function.
Applied to files:
packages/ui/src/cli/commands/install.ts
🧬 Code graph analysis (1)
packages/ui/src/cli/commands/install.ts (1)
packages/ui/src/cli/utils/exec-command.ts (1)
execCommand
(12-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: 🧰 Build
🔇 Additional comments (2)
packages/ui/src/cli/commands/install.ts (2)
32-32
: Good fix: Windows wrapper applied to the update-to-latest path.This addresses the ENOENT on win32 for the “update to latest” flow. LGTM.
40-40
: Consistent application on the regular install path.Same Windows-safe invocation here—nice consistency. LGTM.
Summary by CodeRabbit
Bug Fixes
Chores