[英]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.