执行命令ng test --port 4200
它收到以下错误:
ERROR in ./node_modules/selenium-webdriver/io/exec.js
Module not found: Error: Can't resolve 'child_process' in 'd:\name_project\node_modules\selenium-webdriver\io'
@ ./node_modules/selenium-webdriver/io/exec.js 20:21-45
@ ./node_modules/selenium-webdriver/remote/index.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
ERROR in ./node_modules/selenium-webdriver/net/portprober.js
Module not found: Error: Can't resolve 'child_process' in 'd:\name_project\node_modules\selenium-webdriver\net'
@ ./node_modules/selenium-webdriver/net/portprober.js 22:15-39
@ ./node_modules/selenium-webdriver/remote/index.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
ERROR in ./node_modules/fs.realpath/index.js
Module not found: Error: Can't resolve 'fs' in 'd:\name_project\node_modules\fs.realpath'
@ ./node_modules/fs.realpath/index.js 8:9-22
@ ./node_modules/glob/glob.js
@ ./node_modules/rimraf/rimraf.js
@ ./node_modules/selenium-webdriver/io/index.js
@ ./node_modules/selenium-webdriver/io/zip.js
@ ./node_modules/selenium-webdriver/firefox.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
ERROR in ./node_modules/fs.realpath/old.js
Module not found: Error: Can't resolve 'fs' in 'd:\name_project\node_modules\fs.realpath'
@ ./node_modules/fs.realpath/old.js 24:9-22
@ ./node_modules/fs.realpath/index.js
@ ./node_modules/glob/glob.js
@ ./node_modules/rimraf/rimraf.js
@ ./node_modules/selenium-webdriver/io/index.js
@ ./node_modules/selenium-webdriver/io/zip.js
@ ./node_modules/selenium-webdriver/firefox.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
ERROR in ./node_modules/glob/sync.js
Module not found: Error: Can't resolve 'fs' in 'd:\name_project\node_modules\glob'
@ ./node_modules/glob/sync.js 4:9-22
@ ./node_modules/glob/glob.js
@ ./node_modules/rimraf/rimraf.js
@ ./node_modules/selenium-webdriver/io/index.js
@ ./node_modules/selenium-webdriver/io/zip.js
@ ./node_modules/selenium-webdriver/firefox.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
ERROR in ./node_modules/glob/glob.js
Module not found: Error: Can't resolve 'fs' in 'd:\name_project\node_modules\glob'
@ ./node_modules/glob/glob.js 43:9-22
@ ./node_modules/rimraf/rimraf.js
@ ./node_modules/selenium-webdriver/io/index.js
@ ./node_modules/selenium-webdriver/io/zip.js
@ ./node_modules/selenium-webdriver/firefox.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
ERROR in ./node_modules/rimraf/rimraf.js
Module not found: Error: Can't resolve 'fs' in 'd:\name_project\node_modules\rimraf'
@ ./node_modules/rimraf/rimraf.js 6:9-22
@ ./node_modules/selenium-webdriver/io/index.js
@ ./node_modules/selenium-webdriver/io/zip.js
@ ./node_modules/selenium-webdriver/firefox.js
@ ./node_modules/selenium-webdriver/testing/index.js
@ ./src/app/auth.service.spec.ts
@ ./src \.spec\.ts$
@ ./src/test.ts
我的文件 package.json 包含以下库:
{
"name": "name-project",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.9",
"@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",
"webpack": "^3.11.0",
"zone.js": "^0.8.19"
// ..
},
"devDependencies": {
"@angular/cli": "~1.7.1",
"@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",
"json-loader": "^0.5.7",
"karma": "^2.0.2",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"selenium-webdriver": "^4.0.0-alpha.1",
"webpack-cli": "^2.1.3"
},
"browser": {
"fs": false ,
"child_process": false
}
}
但它没有帮助。我该如何纠正错误?
我只在目录webpack.config.js
./node_modules/.bin/webpack
我应该安装一些库吗?我应该在Chrome浏览器中设置一些内容吗?
我将非常感谢您在解决这些错误方面的帮助和指导。