Skip to content

fix(versions): catch missing nuxt in getNuxtVersion#1307

Open
Flo0806 wants to merge 1 commit intonuxt:mainfrom
Flo0806:fix/init-modules-skip-install
Open

fix(versions): catch missing nuxt in getNuxtVersion#1307
Flo0806 wants to merge 1 commit intonuxt:mainfrom
Flo0806:fix/init-modules-skip-install

Conversation

@Flo0806
Copy link
Copy Markdown
Member

@Flo0806 Flo0806 commented May 7, 2026

🔗 Linked issue

Fixes: #1179

📚 Description

npm create nuxt@latest -- test --template=minimal --modules=eslint --install=false

With --install=false, the template is downloaded but Nuxt is never installed. getNuxtVersion then can't find it and throws an error. The error wasn't caught. Now we simple caught it and the process can finish correctly.

@Flo0806 Flo0806 requested a review from danielroe as a code owner May 7, 2026 13:50
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1307
    
    npm i https://pkg.pr.new/nuxi@1307
    
    npm i https://pkg.pr.new/@nuxt/cli@1307
    

commit: 42e75d4

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3962a1e8-599c-4ccf-a14b-977bbb46240d

📥 Commits

Reviewing files that changed from the base of the PR and between d6b1115 and 42e75d4.

📒 Files selected for processing (1)
  • packages/nuxi/src/utils/versions.ts

📝 Walkthrough

Walkthrough

The getNuxtVersion function in packages/nuxi/src/utils/versions.ts now wraps the readPackageJSON('nuxt', ...) call with .catch(() => null) to convert errors into null rather than propagating them. When the Nuxt package JSON lookup fails, nuxtPkg is set to null, and the downstream fallback logic proceeds as before: returning the resolved version if available, falling back to the project's nuxt dependency, or defaulting to '3.0.0'. No other code in the module is affected.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding error handling for a missing Nuxt package in the getNuxtVersion function.
Description check ✅ Passed The description is directly related to the changeset, explaining the context and reason for catching the missing Nuxt error when --install=false is used.
Linked Issues check ✅ Passed The PR successfully addresses issue #1179 by catching the error that occurs when Nuxt is not installed due to --install=false, allowing the initialization process to complete gracefully.
Out of Scope Changes check ✅ Passed The single-line change is narrowly focused on catching the missing Nuxt package error and directly addresses the linked issue without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@d6b1115). Learn more about missing BASE report.

Files with missing lines Patch % Lines
packages/nuxi/src/utils/versions.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1307   +/-   ##
=======================================
  Coverage        ?   54.53%           
=======================================
  Files           ?       49           
  Lines           ?     1212           
  Branches        ?      338           
=======================================
  Hits            ?      661           
  Misses          ?      453           
  Partials        ?       98           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 7, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing Flo0806:fix/init-modules-skip-install (42e75d4) with main (d6b1115)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when initializing nuxt app with arguments

2 participants