我是Nativescript和Angular的新手,想知道如何生成一个新的组件。我用tns create
创建了一个新项目,然后选择Angular作为Framework和Template。玩了之后,我想添加一个新的组件,但不知道如何。我尝试使用npm安装@nativescript/schematics
,然后尝试tns generate component ...
,但随后出现此异常:
Error: Invalid rule result: Instance of class Promise.
at t.project (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:250:1038)
at t._tryNext (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:30:1878)
at t._next (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:30:1780)
at t.next (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:16:1093)
at e._subscribe (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:74:13873)
at e._trySubscribe (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:16:4641)
at e.subscribe (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:16:4427)
at e.call (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:30:1459)
at e.subscribe (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:16:4299)
at C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:145:10377
at s (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:16:6063)
at t._innerSub (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:30:2033)
at t._tryNext (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:30:1957)
at t._next (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:30:1780)
at t.next (C:\Users\Pascal\AppData\Roaming\npm\node_modules\nativescript\node_modules\@nativescript\schematics-executor\dist\index.js:16:1093)
at SafeSubscriber.__tryOrUnsub (C:\Users\Pascal\AppData\Roaming\npm\node_modules\@nativescript\schematics\node_modules\rxjs\internal\Subscriber.js:207:16)
请参考schematics documentation,请尝试
ng g c component-name