所以我在Termux Android ARM中使用的是Angular版本8。这是来自Angular CLI的角度版本信息:
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.0.2
Node: 12.4.0
OS: android arm
Angular: <error>
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
但是当我使用ng add
命令为我的网站项目添加PWA和服务工作者时,它返回错误:
$ ng add @angular/pwa --project betaleapofazzamgithubio
Workspace needs to be loaded before it is used.
Error: Workspace needs to be loaded before it is used.
at Workspace._assertLoaded (/data/data/com.termux/files/home/node_modules/@angular-devkit/core/src/experimental/workspace/workspace.js:108:19)
at Workspace.getProjectByPath (/data/data/com.termux/files/home/node_modules/@angular-devkit/core/src/experimental/workspace/workspace.js:156:14)
at getProjectByCwd (/data/data/com.termux/files/home/node_modules/@angular/cli/utilities/config.js:103:26)
at Object.getConfiguredPackageManager (/data/data/com.termux/files/home/node_modules/@angular/cli/utilities/config.js:116:25)
at Object.getPackageManager (/data/data/com.termux/files/home/node_modules/@angular/cli/utilities/package-manager.js:32:35)
at new AddCommand (/data/data/com.termux/files/home/node_modules/@angular/cli/commands/add-impl.js:25:49)
at Object.runCommand (/data/data/com.termux/files/home/node_modules/@angular/cli/models/command-runner.js:172:25)
at async default_1 (/data/data/com.termux/files/home/node_modules/@angular/cli/lib/cli/index.js:32:31)
由于该错误,我使用ng generate
命令而不是ng add
命令。但它也返回到错误。这是错误:
$ ng generate service-worker
Workspace needs to be loaded before it is used.
Error: Workspace needs to be loaded before it is used.
at Workspace._assertLoaded (/data/data/com.termux/files/home/node_modules/@angular-devkit/core/src/experimental/workspace/workspace.js:108:19)
at Workspace.getProjectByPath (/data/data/com.termux/files/home/node_modules/@angular-devkit/core/src/experimental/workspace/workspace.js:156:14)
at Object.getProjectByCwd (/data/data/com.termux/files/home/node_modules/@angular/cli/utilities/config.js:103:26)
at GenerateCommand.getDefaultSchematicCollection (/data/data/com.termux/files/home/node_modules/@angular/cli/models/schematic-command.js:251:38)
at GenerateCommand.parseSchematicInfo (/data/data/com.termux/files/home/node_modules/@angular/cli/commands/generate-impl.js:70:35)
at GenerateCommand.initialize (/data/data/com.termux/files/home/node_modules/@angular/cli/commands/generate-impl.js:16:54)
at GenerateCommand.validateAndRun (/data/data/com.termux/files/home/node_modules/@angular/cli/models/command.js:127:20)
at async Object.runCommand (/data/data/com.termux/files/home/node_modules/@angular/cli/models/command-runner.js:178:24)
at async default_1 (/data/data/com.termux/files/home/node_modules/@angular/cli/lib/cli/index.js:32:31)
请为该错误提供帮助,并修复此错误解决方案。
答案 0 :(得分:1)
npm install
ng generate component <componentName> //*for adding new component*
或ng generate service <serviceName> //*for adding new service*