ERESOLVE 无法解析依赖关系树。 .net 核心 3.1 与 vue js

ERESOLVE unable to resolve dependency tree. .net core 3.1 with vue js

我正在尝试构建我的应用程序但出现以下错误

npm ERR! code ERESOLVE
  npm ERR! ERESOLVE unable to resolve dependency tree
  npm ERR!
  npm ERR! While resolving: clientapp@0.1.0
  npm ERR! Found: vue@2.6.14
  npm ERR! node_modules/vue
  npm ERR!   vue@"^2.6.12" from the root project
  npm ERR!
  npm ERR! Could not resolve dependency:
  npm ERR! peer vue@">=3.0.0" from vue-chartkick@1.1.0
  npm ERR! node_modules/vue-chartkick
  npm ERR!   vue-chartkick@"^1.0.0" from the root project
  npm ERR!
  npm ERR! Fix the upstream dependency conflict, or retry
  npm ERR! this command with --force, or --legacy-peer-deps
  npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

知道我遗漏了什么吗

错误 MSB3073:命令“npm install”退出,代码为 1。 我创建构建的 csproj 文件的内容是

<ItemGroup>
    <PackageReference Include="VueCliMiddleware" Version="3.1.2" />
</ItemGroup>
<PropertyGroup>
    <SpaRoot>clientapp\</SpaRoot>
    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<ItemGroup>
    <!-- Don't publish the SPA source files, but do show them in the project files list -->
    <Content Remove="$(SpaRoot)**" />
    <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
</ItemGroup>

<!--<ItemGroup>
    <Folder Include="wwwroot\" />
</ItemGroup>-->
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build">
    <!-- Build Target:  Ensure Node.js is installed -->
    <Exec Command="node --version" ContinueOnError="true">
        <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Exec Command="npm --version" ContinueOnError="true">
        <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
    </Exec>
    <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js and npm are 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." />
</Target>

<Target Name="EnsureNodeModulesInstalled" BeforeTargets="Build" Inputs="package.json" Outputs="packages-lock.json" Condition="!Exists('$(SpaRoot)node_modules')">
    <!-- Build Target: Restore NPM packages using npm -->
    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
</Target>

<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- Build Target: Run webpack dist build -->
    <Message Importance="high" Text="Running npm build..." />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build --modern" />

    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
        <DistFiles Include="$(SpaRoot)dist\**" />
        <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
            <RelativePath>%(DistFiles.Identity)</RelativePath>
            <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
            <ExcludeFromSingleFile>True</ExcludeFromSingleFile>
        </ResolvedFileToPublish>
    </ItemGroup>
</Target>

从错误来看,您似乎安装了 Vue 2,但软件包vue-chartckick 正在寻找 Vue 3。

此外,包自述文件指出:

The latest version works with Vue 3. For Vue 2, use version 0.6.1 and this readme https://github.com/ankane/vue-chartkick/blob/v0.6.1/README.md.

因此,解决方案是使用推荐版本的软件包或将 Vue 升级到版本 3。

有用的是删除 %appdata%\Roaming\npm-cache 文件夹本地 node_modules 文件夹