我试图通过Visual Studio代码运行Angular 5应用程序 - 代码编译没有错误,但我收到了" fs.existsSync不是函数"在localhost上查看时出错:4200。完整的错误消息是
module.exports< devmode.js:33 <anonymous> devmode.js:31 <anonymous> devmode.js:1 ./node_modules/selenium-webdriver/lib/devmode.js http://localhost:4200/vendor.bundle.js:1084:1
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 <anonymous> http.js:32 <anonymous> http.js:1 ./node_modules/selenium-webdriver/lib/http.js http://localhost:4200/vendor.bundle.js:1108:1
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 <anonymous> index.js:29 <anonymous> index.js:1 ./node_modules/selenium-webdriver/http/index.js http://localhost:4200/vendor.bundle.js:1044:1
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 <anonymous> login.component.ts:1 ./src/app/login/login.component.ts http://localhost:4200/main.bundle.js:284:1
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 <anonymous> app.module.ts:24 ./src/app/app.module.ts http://localhost:4200/main.bundle.js:107:1
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 <anonymous> main.ts:4 ./src/main.ts http://localhost:4200/main.bundle.js:403:1
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 [0] http://localhost:4200/main.bundle.js:411:18
__webpack_require__ http://localhost:4200/inline.bundle.js:55:12 webpackJsonpCallback http://localhost:4200/inline.bundle.js:26:23 <anonymous> http://localhost:4200/main.bundle.js:1:1
有关此错误的其他问题提到Electron,但我没有使用该软件包。
我对所有这些都不熟悉,所以不知道我应该提供哪些其他信息。如果有帮助,我的npm版本是5.6.0,节点是版本6.11.0,我的package.json的内容是:
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"ngx-bootstrap": "^2.0.2",
"ngx-cookie-service": "^1.0.10",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@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.5.3"
}
我需要在代码中寻找什么来修复此错误?
由于
答案 0 :(得分:2)
好吧,这似乎是从您的编辑器自动导入的流氓。它是从HttpClient
而不是Angular导入WebDriver
的。
使用这个:
import { HttpClient } from '@angular/common/http';