Angular Nativescript如何修复ng g c上的错误?
刚才我用angular-nativescript创建了项目。我只使用了文档中的命令,安装后我尝试运行此命令:Angular Nativescript如何修复ng g c上的错误?,angular,nativescript,Angular,Nativescript,刚才我用angular-nativescript创建了项目。我只使用了文档中的命令,安装后我尝试运行此命令: ng generate component home 我得到这个错误: 发生未处理的异常:找不到模块 “@schematics/angular/utility/parse name”请参见 “C:\Users\andri\AppData\Local\Temp\ng-JFv0M5\angular errors.log”用于 进一步详情 进一步详情: [错误]错误:找不到模块 “@sch
ng generate component home
我得到这个错误:
发生未处理的异常:找不到模块
“@schematics/angular/utility/parse name”请参见
“C:\Users\andri\AppData\Local\Temp\ng-JFv0M5\angular errors.log”用于
进一步详情
进一步详情:
[错误]错误:找不到模块
“@schematics/angular/utility/parse name”
位于Function.Module.\u resolveFilename(internal/modules/cjs/loader.js:582:15)
at Function.Module.\u load(内部/modules/cjs/loader.js:508:25)
at Module.require(内部/modules/cjs/loader.js:637:17)
根据需要(内部/modules/cjs/helpers.js:22:18)
反对。(C:\Users\andri\AppData\Roaming\npm\node_modules@nativescript\原理图\src\generate\component\index.js:6:22)
at模块编译(内部/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js(internal/modules/cjs/loader.js:712:10)
at Module.load(内部/modules/cjs/loader.js:600:32)
在tryModuleLoad(内部/modules/cjs/loader.js:539:12)
at Function.Module._load(内部/modules/cjs/loader.js:531:3)
我该如何解决这个问题
我的信息:
√ Component nativescript has 6.0.3 version and is up to date.
√ Component tns-core-modules has 6.0.7 version and is up to date.
√ Component tns-android has 6.0.2 version and is up to date.
√ Component tns-ios has 6.0.2 version and is up to date.
Angular CLI: 8.3.0
Node: 10.15.3
Angular: 8.2.3
@angular-devkit/architect 0.803.0 (cli-only)
@angular-devkit/core 8.2.2
@angular-devkit/schematics 8.3.0
@ngtools/webpack 8.2.2
@schematics/angular 8.3.0
@schematics/update 0.803.0 (cli-only)
rxjs 6.5.2
typescript 3.5.3
webpack 4.27.1
您可以通过执行以下命令来解决此问题:
npm uninstall -g @angular/cli
yarn global add @angular/cli
如需进一步帮助,请遵循此说明,因为这似乎是同一问题的副本。请尝试此说明
npm卸载-g@angular/cli
那么
npm安装-g@angular/cli我这样做了:
npm安装-g@schematics/angular
这为我解决了这个问题。我通过在项目中安装angular CLI解决了这个问题
npm install -D @angular/cli
然后使用npx运行命令
npx ng generate component home
希望这对我有帮助
npm i -D @nativescript/schematics
npm i -D @angular/cli
ng g c test
我在Nativescript的
ng g
中也遇到了类似的问题,所以它可能会对某些人有所帮助
可能的错误:
An unhandled exception occurred: Could not find module "@nativescript/schematics" from
An unhandled exception occurred: Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'
An unhandled exception occurred: Cannot find module 'tslint'
对于tns--version
:6.3.3
缺少以下依赖项:@nativescript/schematics
@schematics/angular
tslint
要使其工作,请运行:
npm i -D @nativescript/schematics @schematics/angular tslint
以下几点对我很有用:
npm i -D @nativescript/schematics
npm i -D @angular/cli
ng g c test
- 使用以下工具安装angular cli的最新版本:
npm install -g @angular/cli"
- 从项目中删除
和node\u模块
package lock.json
- 运行:
npm install
找不到模块'@schematics/angular/utility/config'