我想在heroku上部署Angular 9项目,这是我的第一次。在本地,构建(ng build
)和serve cmd(ng serve
)正常。但是,在Heroku上进行部署时,我总是遇到相同的错误(NG8002:无法绑定到“ ngModel”,因为它不是“ input”的已知属性)。请问您有个主意吗?谢谢
编辑:我检查了FormsModule是否位于app.modules.ts文件的imports数组中
BuildLog
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 12.x
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.2...
Using default npm version: 6.14.5
-----> Installing dependencies
Installing node modules (package.json + package-lock)
> core-js@3.6.4 postinstall /tmp/build_4ccf2c908fb7cea49aeed2c537b8ad54/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> @angular/cli@9.1.8 postinstall /tmp/build_4ccf2c908fb7cea49aeed2c537b8ad54/node_modules/@angular/cli
> node ./bin/postinstall/script.js
added 1566 packages from 1224 contributors and audited 1571 packages in 49.807s
53 packages are looking for funding
run `npm fund` for details
found 296 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
Running build
> pubmed-map-angular@0.0.0 build /tmp/build_4ccf2c908fb7cea49aeed2c537b8ad54
> ng build
Compiling @angular/core : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/animations/browser/testing : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
ERROR in src/app/common/auth/login/login.component.html:10:67 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
10 <input type="text" class="form-control" name="username" [(ngModel)]="form.username" required />
~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/common/auth/login/login.component.ts:10:16
10 templateUrl: './login.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component LoginComponent.
src/app/common/auth/login/login.component.html:17:71 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
17 <input type="password" class="form-control" name="password" [(ngModel)]="form.password" required minlength="6" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/common/auth/login/login.component.ts:10:16
10 templateUrl: './login.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component LoginComponent.
src/app/common/auth/register/register.component.html:10:61 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
10 <input type="text" class="form-control" name="name" [(ngModel)]="form.name" required />
~~~~~~~~~~~~~~~~~~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/register/register.component.html:16:67 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
16 <input type="text" class="form-control" name="username" [(ngModel)]="form.username" #username="ngModel" required />
~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/register/register.component.html:24:62 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
24 <input type="text" class="form-control" name="email" [(ngModel)]="form.email" #email="ngModel" required email />
~~~~~~~~~~~~~~~~~~~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/register/register.component.html:32:69 - error NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'.
32 <input type="password" class="form-control" name="password" [(ngModel)]="form.password" #password="ngModel" required minlength="6" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/common/auth/register/register.component.ts:[93m9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/login/login.component.html:7:69 - error NG8003: No directive found with exportAs 'ngForm'.
7 <form name="form" (ngSubmit)="f.form.valid && onSubmit()" #f="ngForm" novalidate>
~~~~~~
src/app/common/auth/login/login.component.ts:10:16
10 templateUrl: './login.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component LoginComponent.
src/app/common/auth/register/register.component.html:16:106 - error NG8003: No directive found with exportAs 'ngModel'.
16 <input type="text" class="form-control" name="username" [(ngModel)]="form.username" #username="ngModel" required />
~~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/register/register.component.html:24:95 - error NG8003: No directive found with exportAs 'ngModel'.
24 <input type="text" class="form-control" name="email" [(ngModel)]="form.email" #email="ngModel" required email />
~~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/register/register.component.html:32:108 - error NG8003: No directive found with exportAs 'ngModel'.
32 <input type="password" class="form-control" name="password" [(ngModel)]="form.password" #password="ngModel" required minlength="6" />
~~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
src/app/common/auth/register/register.component.html:7:67 - error NG8003: No directive found with exportAs 'ngForm'.
7 <form name="form" (ngSubmit)="f.form.valid && onSubmit()" #f="ngForm" novalidate>
~~~~~~
src/app/common/auth/register/register.component.ts:9:16
9 templateUrl: './register.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RegisterComponent.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pubmed-map-angular@0.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pubmed-map-angular@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.3FGPj/_logs/2020-07-13T15_38_16_812Z-debug.log
-----> Build failed```