简体   繁体   English

为什么在 angular 的 nx 工作区中创建应用程序时找不到模块“typescript”?

[英]Why i am getting can't find module "typescript" when creating an application inside nx workspace in angular?

I have created an nx workspace which is successfully generated.我创建了一个成功生成的nx workspace Now i am generating a micro-front-end app inside that nx workspace using this command现在我正在使用此命令在该nx工作区中生成一个micro-front-end应用程序

npx nx g @nrwl/angular:app opShell --mfe --mfeType=host --routing=true

So i am getting this error所以我收到了这个错误

Cannot find module 'typescript'
Require stack:
- D:\Office\OP-MFE\node_modules\@nrwl\angular\node_modules\@nrwl\workspace\src\utilities\typescript\compilation.js
- D:\Office\OP-MFE\node_modules\@nrwl\angular\node_modules\@nrwl\workspace\src\utilities\typescript.js
- D:\Office\OP-MFE\node_modules\@nrwl\angular\node_modules\@nrwl\workspace\index.js
- D:\Office\OP-MFE\node_modules\@nrwl\angular\src\generators\application\application.js
- D:\Office\OP-MFE\op-mfe\node_modules\@nrwl\tao\src\shared\workspace.js
- D:\Office\OP-MFE\op-mfe\node_modules\@nrwl\cli\lib\init-local.js
- D:\Office\OP-MFE\op-mfe\node_modules\@nrwl\cli\bin\nx.js
- C:\Users\Fahad Subzwari\AppData\Roaming\npm\node_modules\nx\node_modules\@nrwl\cli\bin\nx.js
- C:\Users\Fahad Subzwari\AppData\Roaming\npm\node_modules\nx\bin\nx.js



OS Details
-Node: 14.7.6
-AngularCLI:12.0.0

Current Dirrectory Structure当前目录结构

nx workspace nx 工作区

   -opMfe
     -node_modules
     -op-mfe 
       -apps
       -libs
       -node_modules
       -tools
       -nx.json
       -package.json
       -workspace.json
     -package-lock

package.json package.json

{
  "name": "op-mfe",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "start": "nx serve",
    "build": "nx build",
    "test": "nx test"
   },
 "private": true,
 "dependencies": {},
 "devDependencies": {
    "@nrwl/tao": "13.4.2",
    "@nrwl/cli": "13.4.2",
    "@nrwl/workspace": "13.4.2",
    "@types/node": "14.14.33",
    "typescript": "~4.4.3",
    "prettier": "^2.3.1"
  }
}

i am running this command npx nx g @nrwl/angular:app opShell --mfe --mfeType=host --routing=true at opMfe/op-mfe folder.我在 opMfe/op-mfe 文件夹中运行此命令npx nx g @nrwl/angular:app opShell --mfe --mfeType=host --routing=true So it's giving an error which i just mentioned in the beginning.所以它给出了我刚开始提到的错误。

what can be the issue here?这里有什么问题?

You are trying to generate an Angular app but we can see in your package.json that you don't have @nrwl/angular installed.您正在尝试生成 Angular 应用程序,但我们可以在您的package.json中看到您没有安装@nrwl/angular

Running the following command and try again should fix the issue:运行以下命令并重试应该可以解决问题:

npm install --save-dev @nrwl/angular

See full tutorial on how to setup module federation with angular and nx at https://nx.dev/guides/setup-mfe-with-angular .请参阅https://nx.dev/guides/setup-mfe-with-angular中有关如何使用 angular 和 nx 设置模块联合的完整教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在一个Nx工作区中同时为Angular和React应用程序使用NX CLI吗? - Can I use NX CLI for both Angular and React apps in one Nx workspace? 为什么我在 Angular 中出现错误。 无法获取 / - Why I am getting error in Angular. can't GET / 为什么我在使用任何 `nx` 命令时都会出错 - Why am i getting error on using any `nx` commands 当我在功能模块中将服务指定为提供者时,为什么在 Angular 中没有提供服务提供者 - Why am I getting No Provider for a Service in Angular when i have specified the service as a provider in the Feature Module 我正在获取找不到模块'@ angular / compiler-cli' - I am getting the cannot find module '@angular/compiler-cli' Typescript-在模块内找不到构造方法 - Typescript - Can't find the constructor method inside the module 如何在 NX 工作区中运行特定的 angular 规范测试文件? - how can i run a specific angular spec test file in NX workspace? Angular NX 工作区:出现错误“缺少必需的属性'main' - Angular NX workspace: getting error "Required property 'main' is missing 在Angular应用程序中,我不断收到此错误找不到模块'fs' - In Angular application, I keep getting this error Cannot find module 'fs' Angular 4 找不到在模块内创建的组件 - Angular 4 can't find component created inside a module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM