Nativescript 项目无法 运行 ng 服务

Nativescript project cannot run ng serve

如果我尝试运行以下命令,会发生这种情况:

ng serve
An unhandled exception occurred: No projects support the 'serve' target.
See "/tmp/ng-YKKFYj/angular-errors.log" for further details.

与angular.json、package.json、src文件夹等同目录,见:

forest@forest:~/<project-path>$ ls -lsa
total 380
  4 drwxrwxr-x   8 forest forest   4096 dec   17 17:44 .
  4 drwxrwxr-x   7 forest forest   4096 dec   17 16:20 ..
  4 -rw-r--r--   1 forest forest    383 okt   26  1985 angular.json
  4 drwxrwxr-x   4 forest forest   4096 dec   12 14:16 App_Resources
  4 -rw-r--r--   1 forest forest    202 okt   26  1985 .editorconfig
  4 -rw-r--r--   1 forest forest    260 dec   17 15:43 .gitignore
  4 drwxrwxr-x   5 forest forest   4096 dec   17 14:02 hooks
  4 drwxr-xr-x   3 root   root     4096 dec   13 15:41 .idea
 12 -rw-r--r--   1 forest forest  11368 okt   26  1985 LICENSE
 20 drwxrwxr-x 567 forest forest  20480 dec   17 16:15 node_modules
  4 -rw-r--r--   1 forest forest     62 okt   26  1985 nsconfig.json
  4 -rw-rw-r--   1 forest forest   1315 dec   17 16:15 package.json
264 -rw-rw-r--   1 forest forest 267877 dec   17 16:15 package-lock.json
  4 drwxrwxr-x   3 forest forest   4096 dec   17 16:04 platforms
  4 drwxrwxr-x   4 forest forest   4096 dec   17 15:26 src
  4 -rw-r--r--   1 forest forest    670 dec   17 16:34 tsconfig.json
  4 -rw-r--r--   1 forest forest    126 okt   26  1985 tsconfig.tns.json
  4 -rw-r--r--   1 forest forest     38 okt   26  1985 tsfmt.json
  4 -rw-rw-r--   1 forest forest   3093 dec   17 17:44 tslint.json
  4 -rw-r--r--   1 forest forest   1575 dec   12 18:16 tslint_old.json
 16 -rw-rw-r--   1 forest forest  14103 dec   17 13:23 webpack.config.js
forest@forest:~/<project-path>$ ng serve
An unhandled exception occurred: No projects support the 'serve' target.                                                                                                                                           
See "/tmp/ng-dO1bgr/angular-errors.log" for further details.                                                                                                                                                       

版本:

$ng --version:
Angular CLI: 8.3.19
Node: 12.3.1
OS: linux x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.19 (cli-only)
@angular-devkit/core         8.2.2
@angular-devkit/schematics   8.3.19 (cli-only)
@ngtools/webpack             8.2.2
@schematics/angular          8.3.19 (cli-only)
@schematics/update           0.803.19 (cli-only)
rxjs                         6.5.3
typescript                   3.5.3
webpack                      4.27.1

$tns --version
6.2.2

虽然可以为 Android 构建项目。

您应该将 Schematics 用于代码共享项目,该项目完成 Web 和 iOS / Android 的所有设置。

如果您是从模板创建的,您可能需要手动配置项目以支持 Web。