我正在尝试使用agm来自动竞争表单字段。我只是使用命令npm install @agm/core
安装的,在app.module
中,我在导入中添加了AgmCoreModule
。我没有使用任何与agm相关的代码,保存了项目并运行ng serve
并收到此错误。
agm-core.js:4538 Uncaught TypeError: Object(...) is not a function
at agm-core.js:4538
at Module.../../node_modules/@agm/core/fesm5/agm-core.js (agm-core.js:4544)
at __webpack_require__ (bootstrap:78)
at Module../src/app/app.module.ts (app.component.ts:12)
at __webpack_require__ (bootstrap:78)
at Module../src/main.ts (main.ts:1)
at __webpack_require__ (bootstrap:78)
at Object.0 (main.ts:12)
at __webpack_require__ (bootstrap:78)
at checkDeferredModules (bootstrap:45)
我不知道这是什么意思。请告诉我是什么问题。
这是我的package.json
文件依赖关系和开发人员依赖关系。
"dependencies": {
"@angular-material-extensions/google-maps-autocomplete": "^2.0.0",
"@angular/animations": "^7.2.15",
"@angular/cdk": "^7.2.0",
"@angular/common": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/flex-layout": "^7.0.0-beta.24",
"@angular/forms": "~7.2.0",
"@angular/material": "^7.2.0",
"@angular/material-moment-adapter": "^8.2.3",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"and": "0.0.3",
"angular-mgl-timeline": "^0.3.2",
"angular2-text-mask": "^9.0.0",
"bootstrap": "^4.3.1",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"moment": "^2.24.0",
"ngx-bootstrap": "^5.2.0",
"ngx-pagination": "^4.1.0",
"ngx-toastr": "^10.2.0",
"rxjs": "^6.5.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"},
"devDependencies": {
"@angular-devkit/build-angular": "~0.12.0",
"@angular/cli": "^7.2.1",
"@angular/compiler": "^7.2.15",
"@angular/compiler-cli": "^7.2.0",
"@angular/language-service": "~7.2.0",
"@types/googlemaps": "^3.38.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"node-sass": "^4.13.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"}
如果删除导入,一切正常,但是如果再次添加错误,则停止项目运行。
答案 0 :(得分:4)
或将您的Agm版本更改为
删除当前版本:
npm卸载@ agm / core
然后安装此版本:
npm i @ agm / core @ 1.0.0-beta.7-保存
答案 1 :(得分:3)
我正在用angular 7开发并在应用程序中使用agm模块。 错误地,我只是重新安装了AGM核心模块。 安装完成后,它给了我同样的错误。 agm版本“ ^ 1.1.0”与angular 7不兼容。 修复了我只是将package.json中的@ agm / core:“ ^ 1.1.0”更改为“ 1.0.0”
答案 2 :(得分:3)
或将您的Agm版本更改为
删除当前版本:
npm uninstall @agm/core
然后安装此版本:
npm i @agm/core@1.0.0-beta.7 --save
对我来说很完美
答案 3 :(得分:1)
// Edit your app.module.ts
import { AgmCoreModule } from '@agm/core'
@NgModule({
declarations: [],
// Add this also
imports: [
AgmCoreModule.forRoot({
apiKey: 'your key',
libraries: ['places']
}),
],
providers: [],
bootstrap: [AppComponent]
})
答案 4 :(得分:0)
// import the core module
import { AgmCoreModule } from '@agm/core'
// add it to your app.module's imports like so
AgmCoreModule.forRoot({
apiKey: 'your key',
libraries: ['places']
}),
答案 5 :(得分:0)
AGM模块的1.1.0版本已于昨天发布,我相信它使用的是Angular8。我们不得不恢复到1.0.0才能使用Angular7。
答案 6 :(得分:0)
为了与 Angular 7 配合使用,我们不得不恢复到 1.0.0。
或将您的 Agm 版本更改为
删除您当前的版本:
npm 卸载 @agm/core
然后安装这个版本:
npm i @agm/core@1.0.0-beta.7 --save