我是Angle 6的新手,我已经从link下载了现成的angular模板

导航到根文件夹并执行npm install尝试运行应用程序ng serve,但显示错误



package.json

{
  "name": "angular-6-registration-login-example",
  "version": "1.0.0",
  "repository": {
    "type": "git",
    "url": "https://github.com/cornflourblue/angular-6-registration-login-example.git"
  },
  "scripts": {
    "build": "webpack --mode production",
    "start": "webpack-dev-server --mode development --open"
  },
  "license": "MIT",
  "dependencies": {
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "core-js": "^2.5.5",
    "rxjs": "^6.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@types/node": "^10.0.4",
    "angular2-template-loader": "^0.6.2",
    "html-webpack-plugin": "^3.2.0",
    "raw-loader": "^0.5.1",
    "ts-loader": "^4.3.0",
    "typescript": "^2.8.3",
    "webpack": "4.8.1",
    "webpack-cli": "^2.1.3",
    "webpack-dev-server": "3.1.4"
  }
}

我的环境配置是
Angular CLI: 6.0.3
Node: 8.11.2
OS: linux x64
Angular: 6.0.3
... common, compiler, core, forms, platform-browser
... platform-browser-dynamic, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.3 (cli-only)
@angular-devkit/core         0.6.3 (cli-only)
@angular-devkit/schematics   0.6.3 (cli-only)
@schematics/angular          0.6.3 (cli-only)
@schematics/update           0.6.3 (cli-only)
rxjs                         6.2.0
typescript                   2.8.4
webpack                      4.8.1

请帮助我解决这个问题。

最佳答案

由于您的项目不使用Angular-CLI,因此您无法执行ng serve,这会导致错误,因为ng serve会寻找此配置文件来启动您的应用



它使用webpack,所有webpack配置都存储在webpack.config.js中。
如果您观察package.json,可以在脚本部分startbuild下看到

"scripts": {
    "build": "webpack --mode production",
    "start": "webpack-dev-server --mode development --open"
  },

您可以使用npm执行这些脚本
执行npm run start进行开发

09-27 12:49