微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Nativescript + Angular 项目错误:发生未处理的异常:找不到模块 '@schematics/angular/utility/parse-name'

如何解决Nativescript + Angular 项目错误:发生未处理的异常:找不到模块 '@schematics/angular/utility/parse-name'

我是 nativescript 开发的新手,我正在尝试使用以下命令创建一个新组件: ng g c 组件名称

我得到的错误是: 发生未处理的异常:找不到模块 '@schematics/angular/utility/parse-name'

我已经运行了以下内容

npm i -D @nativescript/schematics @schematics/angular tslint

即使我安装了@schematics/angular 9.1.0 版,我也会收到以下错误

Could not find an NgModule. Use the skip-import option to skip importing in NgModule

我不想通过跳过导入来创建组件,而是希望组件自动添加到模块中。

即使我确实跳过了对模块的导入,我也会在组件的 TS 类中收到以下错误

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.ts(1219)

这在 tsconfig 中设置为 true,所以不知道如何解决以上所有问题!

TNS 设置正确,运行 tns doctor 后显示没有问题。

Angular 和 nativescript 版本是最新的:

Angular CLI:11.1.1 节点:10.23.1 操作系统:达尔文 x64

Angular: 11.0.9
... animations,common,compiler,compiler-cli,core,forms
... platform-browser,platform-browser-dynamic,router
Ivy Workspace: Yes

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1101.1 (cli-only)
@angular-devkit/core         10.0.8
@angular-devkit/schematics   11.1.1 (cli-only)
@ngtools/webpack             11.0.7
@schematics/angular          11.1.1 (cli-only)
@schematics/update           0.1101.1 (cli-only)
rxjs                         6.6.3
typescript                   4.0.5

TNS 医生:

No issues were detected.
    ✔ Your ANDROID_HOME environment variable is set and points to correct directory.
    ✔ Your adb from the Android SDK is correctly installed.
    ✔ The Android SDK is installed.
    ✔ A compatible Android SDK for compilation is found.
    ✔ Javac is installed and is configured properly.
    ✔ The Java Development Kit (JDK) is installed and is configured properly.
    ✔ Xcode is installed and is configured properly.
    ✔ xcodeproj is installed and is configured properly.
    ✔ CocoaPods are installed.
    ✔ CocoaPods update is not required.
    ✔ CocoaPods are configured properly.
    ✔ Your current CocoaPods version is newer than 1.0.0.
    ✔ Python installed and configured correctly.
    ✔ The Python 'six' package is found.
    ✔ Xcode version 12.3.0 satisfies minimum required version 10.
    ✔ Getting NativeScript components versions information...
    ✔ Component nativescript has 7.1.2 version and is up to date.

解决方法

在 angular.json 中删除

"cli": {​​

"defaultCollection": "@nativescript/schematics","analytics": false

}​​,

ng g c your-component

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。