Skip to content

npm run new fails when VS Code CLI is not installed #2781

Open
@2nofa11

Description

@2nofa11

name: Bug report
about: Create a report to help us improve

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.17.0 (development environment issue, not rule-specific)
  • eslint-plugin-vue version: 10.2.0
  • Vue version: 3.x (development environment issue, not app-specific)
  • Node version: v23.11.0
  • Operating System: macOS (Darwin 24.5.0)

Please show your full configuration:
This is a development tooling issue with npm run new command.

What did you do?

npm run new <rule-name> <author>

What did you expect to happen?

The command should complete successfully without errors, providing a smooth experience for new contributors following the developer guide.

What actually happened?

The command generates files successfully but fails at the end when trying to automatically open files in VS Code:

/bin/sh: code: command not found
Error: Command failed: code "path/to/generated/file"
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:882:11)
    at Object.execSync (node:child_process:954:15)
    at /path/to/tools/new-rule.js:143:6

The issue occurs because the script assumes VS Code CLI (code command) is installed, but many developers use other editors (like Cursor, Vim, etc.) or don't have VS Code command line tools available. This creates a poor first impression for new contributors.

Repository to reproduce this issue

This issue can be reproduced on any system where VS Code command line tools are not installed. The problem is in tools/new-rule.js:143-145 where it executes code command without error handling to open generated files automatically.

Suggested Solution

Add graceful fallback when code command is not available:

try {
  cp.execSync(`code "${ruleFile}"`, { stdio: 'ignore' })
} catch (err) {
  // Continue silently if VS Code is not available
  console.log('Files generated successfully')
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions