当我尝试让 Angular/cli 为我生成一个新组件时,它所做的只是打印消息
\nthis.tree.readText is not a function\nRun Code Online (Sandbox Code Playgroud)\n并退出。
\n我正在使用 Ubuntu 22.04 并ng在控制台窗口中使用。\n我正在尝试在功能模块中生成新组件。ng我使用以下命令从功能模块目录开始:
ng g c components/my-new-component --change-detection OnPush\nRun Code Online (Sandbox Code Playgroud)\n工作目录类似于:
\n~/Develop/my-project/src/app/feature-module\nRun Code Online (Sandbox Code Playgroud)\n我期望在新文件夹中生成四个新文件
\n~/Develop/my-project/src/app/feature-module/components/my-new-component/\nRun Code Online (Sandbox Code Playgroud)\n以及模块文件
\n~/Develop/my-project/src/app/feature-module/feature-module.module.ts\nRun Code Online (Sandbox Code Playgroud)\n使用新生成的组件进行更新。
\n我在 Ubunut 20.04 上也遇到了这种情况。\n一位同事在他的 Mac(M1)上使用ng命令行时也遇到了同样的问题,但并没有真正受到阻碍,因为他使用 IntelliJ 并且有用于生成新组件的扩展,而不是使用命令行。
我尝试用谷歌搜索这个问题,但没有成功。我还尝试删除 node_modules 以及 package-lock.json 文件并重新安装所有包,但无济于事。
\n我正在使用以下节点/打字稿/角度版本:
\n _ _ ____ _ ___\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| …Run Code Online (Sandbox Code Playgroud)