Angula2 Karma无法加载"Webpack"! [英] Angula2 Karma Can not load "webpack"!

查看:142
本文介绍了Angula2 Karma无法加载"Webpack"!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在一个Angular2项目(Webpack + Karma)上工作了几个月,该项目基于此启动器的稍旧版本: https://github.com/preboot/angular2-webpack

I have been working on an Angular2 project (Webpack + Karma) for a couple of months now which bases on a slightly older version of this starter: https://github.com/preboot/angular2-webpack

一切正常,直到我在另一台计算机上签出项目为止.使用

Everything had been working fine until I checked my project out on a different computer. After installing the dependencies using

npm install

我试图进行测试.这是出现此错误消息的地方,我无法解释....

I tried to run my tests. This is where this error msg appeared which I can not explain ....

Can not load "webpack"!
WebpackOptionsValidationError: Invalid configuration object.
Webpack has been initialised using a configuration object that does 
not match the API schema.

很长一段时间我都没有更改package.json中的任何内容:

I have not changed anything in my package.json for a long time:

{
"name": "app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
  "clean": "rimraf node_modules doc dist && npm cache clean",
  "clean-install": "npm run clean && npm install",
  "clean-start": "npm run clean-install && npm start",
  "watch": "webpack --watch --progress --profile",
  "build": "rimraf dist && webpack --progress --profile --bail",
  "server": "webpack-dashboard -- webpack-dev-server --inline --port 8080",
  "webdriver-update": "webdriver-manager update",
  "webdriver-start": "webdriver-manager start",
  "lint": "tslint --force \"src/**/*.ts\"",
  "e2e": "protractor",
  "e2e-live": "protractor --elementExplorer",
  "pretest": "npm run lint",
  "test": "karma start",
  "posttest": "remap-istanbul -i coverage/json/coverage-final.json -o coverage/html -t html",
  "test-watch": "karma start --no-single-run --auto-watch",
  "ci": "npm run e2e && npm run test",
  "docs": "typedoc --options typedoc.json src/app/app.component.ts",
  "start": "npm run server",
  "start:hmr": "npm run server -- --hot",
  "postinstall": "npm run webdriver-update"
},
"dependencies": {
  "@angular/common": "2.2.0",
  "@angular/compiler": "2.2.0",
  "@angular/core": "2.2.0",
  "@angular/forms": "2.2.0",
  "@angular/http": "2.2.0",
  "@angular/platform-browser": "2.2.0",
  "@angular/platform-browser-dynamic": "2.2.0",
  "@angular/router": "3.2.0",
  "core-js": "^2.4.1",
  "reflect-metadata": "^0.1.3",
  "rxjs": "5.0.0-beta.12",
  "zone.js": "^0.6.25"
},
"devDependencies": {
  "@angularclass/hmr": "^1.0.1",
  "@angularclass/hmr-loader": "^3.0.2",
  "@types/core-js": "^0.9.0",
  "@types/jasmine": "^2.2.29",
  "@types/node": "^6.0.38",
  "@types/selenium-webdriver": "2.53.33",
  "angular2-template-loader": "^0.6.0",
  "autoprefixer": "^6.3.2",
  "awesome-typescript-loader": "^2.2.4",
  "codelyzer": "1.0.0-beta.3",
  "copy-webpack-plugin": "^4.0.0",
  "css-loader": "^0.25.0",
  "extract-text-webpack-plugin": "^2.0.0-beta.4",
  "file-loader": "^0.9.0",
  "html-loader": "^0.4.0",
  "html-webpack-plugin": "^2.8.1",
  "istanbul-instrumenter-loader": "^0.2.0",
  "jasmine-core": "^2.3.4",
  "jasmine-spec-reporter": "^2.4.0",
  "json-loader": "^0.5.3",
  "karma": "1.3.0",
  "karma-chrome-launcher": "^2.0.0",
  "karma-coverage": "^1.0.0",
  "karma-jasmine": "^1.0.2",
  "karma-mocha-reporter": "^2.0.3",
  "karma-phantomjs-launcher": "^1.0.0",
  "karma-remap-istanbul": "0.2.1",
  "karma-sourcemap-loader": "^0.3.7",
  "karma-webpack": "1.8.0",
  "node-sass": "^3.4.2",
  "null-loader": "0.1.1",
  "phantomjs-prebuilt": "^2.1.4",
  "postcss-loader": "^1.1.0",
  "protractor": "^4.0.10",
  "raw-loader": "0.5.1",
  "remap-istanbul": "^0.6.4",
  "rimraf": "^2.5.1",
  "sass-loader": "^4.0.0",
  "shelljs": "^0.7.0",
  "style-loader": "^0.13.0",
  "ts-helpers": "^1.1.1",
  "tslint": "^3.4.0",
  "tslint-loader": "^2.1.0",
  "typedoc": "^0.5.1",
  "typescript": "2.0.6",
  "url-loader": "^0.5.6",
  "webpack": "^2.1.0-beta.25",
  "webpack-dashboard": "^0.2.0",
  "webpack-dev-server": "2.1.0-beta.9"
}

}

有人知道这里发生了什么吗?

Is there anyone who would know what is going on here?

推荐答案

Webpack 2.2.0或其相关性之一似乎是一个问题.如果将"webpack": "^2.1.0-beta.25"替换为"webpack": "2.2.0-rc.3",将再次起作用. rc.4是它打破的重点

It appears to be an issue with Webpack 2.2.0 or one of its dependancies. If you replace "webpack": "^2.1.0-beta.25" with "webpack": "2.2.0-rc.3" with will work again. rc.4 is the point it broke

这篇关于Angula2 Karma无法加载"Webpack"!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆