1

我试图将我的 angular 5 代码迁移到 angular 6。

将 elasticsearch 客户端从 "elasticsearch": "^14.2.1" 迁移到 "elasticsearch": "^14.2.2" 后,我在启动角度代码时收到以下错误。

npm start

ERROR in ./node_modules/elasticsearch/src/lib/utils.js
Module not found: Error: Can't resolve 'path' in 
'\ui_angular_6\node_modules\elasticsearch\src\lib'
: Failed to compile.

包.json

"dependencies": {
"@angular/animations": "6.0.0",
"@angular/common": "6.0.0",
"@angular/compiler": "6.0.0",
"@angular/core": "6.0.0",
"@angular/flex-layout": "^5.0.0-beta.14",
"@angular/forms": "6.0.0",
"@angular/http": "6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/router": "6.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.1.2",
"angular-datatables": "^5.0.0",
"angular-font-awesome": "^3.1.2",
"body-parser": "^1.18.2",
"bootstrap": "^4.1.0",
"core-js": "^2.4.1",
"elasticsearch": "^14.2.2",
"express": "^4.16.3",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"ng2-pdf-viewer": "^4.1.2",
"popper.js": "^1.14.3",
"rxjs": "^6.1.0",
"rxjs-compat": "^6.1.0",
"underscore": "^1.8.3",
"zone.js": "^0.8.26"
},
 "devDependencies": {
"@angular/cli": "6.0.0",
"@angular/compiler-cli": "6.0.0",
"@angular/language-service": "6.0.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/jquery": "^3.3.1",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "^2.7.2",
"@angular-devkit/build-angular": "~0.6.0"

}

请帮我解决这个问题。

4

2 回答 2

1

将 Elastic 搜索客户端更新到 15.1.1 解决了我的问题

"elasticsearch": "^15.1.1",
于 2018-07-18T20:36:39.183 回答
0

使用下面的这一行安装需要的依赖项

npm i --save util events lodash url querystring http https agentkeepalive zlib
于 2018-07-26T19:40:33.923 回答