You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2022初始化.NET6独立Vue项目后显示为空的问题排查与解决

解决VS2022创建.NET6独立Vue项目后显示为空的问题

我最近遇到了一个非常诡异的问题,分享出来给同样踩坑的朋友参考:

问题背景

严格按照官方指南安装了node.js、npm、vue、vue-cli等所有前置依赖,用VS2022创建基于.NET6的独立Vue项目时,命令窗口明确提示初始化运行成功,但打开项目后却发现界面是空的,完全看不到Vue项目的文件结构。

排查步骤

  • 首先怀疑是依赖安装有问题,卸载并重新安装了node.js,确认版本兼容,但问题依旧
  • 前往项目目标文件夹检查,发现所有必要的Vue项目文件(src目录、package.json等)其实都已经存在,只是VS2022没有显示出来

最终解决方案

折腾了各种方法都没用,最后尝试通过VS安装程序卸载了其他额外的语言包,将VS2022的界面语言改回英文,重新打开项目后,所有文件都正常显示了,目前项目运行一切正常。

项目配置参考

附上我的项目文件内容,供大家核对:

<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/0.4.0-alpha">
  <PropertyGroup Label="Globals">
    <ProjectGuid>...</ProjectGuid>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <StartupCommand>npm run serve</StartupCommand>
    <JavaScriptTestRoot>.\</JavaScriptTestRoot>
    <JavaScriptTestFramework>Jest</JavaScriptTestFramework>
  </PropertyGroup>
  <ItemGroup>
    <Script Include="**" Exclude="*.esproj;**\node_modules\**" />
  </ItemGroup>
  <!-- This target is copied from the ASP.NET SPA template in order to ensure node_modules are in place. -->
  <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
    <!-- Ensure Node.js is installed -->
    <Exec Command="node --version" ContinueOnError="true">
      <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
  </Target>
</Project>

内容的提问来源于stack exchange,提问作者Sam San

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 06:51:00