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

NativeScript项目迁移后chart-directives入口点依赖缺失报错如何解决

问题根因

你当前项目使用的是 NativeScript 8.1 + Angular 12 技术栈,而安装的 nativescript-ui-chart@7.1.0 是适配 NativeScript 7 以下版本的旧版组件,其内部依赖已经废弃的 tns-core-modules、nativescript-angular 包(NS8+ 后这两个包已分别重命名为 @nativescript/core 和 @nativescript/angular),所以 ngcc 编译该组件的 chart-directives 入口时会找不到对应依赖,直接导致编译失败。

解决方案
  • 第一步:卸载旧版不兼容的图表组件
    执行命令:npm uninstall nativescript-ui-chart
  • 第二步:安装适配 NS8+ 的官方新版图表组件
    执行命令:npm install @nativescript/ui-chart
  • 第三步:清理缓存并重装所有依赖,避免旧编译产物干扰
    依次执行以下命令:
    ns clean
    rm -rf node_modules package-lock.json
    npm install
    
  • 第四步:修改项目中所有相关导入路径
    所有旧命名空间的导入都需要同步替换:
    • 把 import ... from 'nativescript-ui-chart' 全部替换为 import ... from '@nativescript/ui-chart'
    • 全局排查项目中有没有直接导入 tns-core-modules/*、nativescript-angular/* 的代码,分别替换为 @nativescript/core/*、@nativescript/angular/*
  • 额外排查项:你 package.json 中其他旧版 NativeScript 插件(比如 nativescript-ui-autocomplete@6.0.0、nativescript-barcodescanner@3.4.2 等)也可能存在 NS8 适配问题,建议同步更新到对应支持 NS8 的最新版本,避免后续出现同类依赖缺失错误。

内容的提问来源于stack exchange,提问作者guillermo sanchez

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.02 10:54:03