问题
I have following package.json configuration
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/router": "3.2.1",
"@angular2-material/button": "^2.0.0-alpha.8-2",
"@angular2-material/button-toggle": "^2.0.0-alpha.8-2",
"@angular2-material/card": "^2.0.0-alpha.8-2",
"@angular2-material/checkbox": "^2.0.0-alpha.8-2",
"@angular2-material/core": "^2.0.0-alpha.8-2",
"@angular2-material/grid-list": "^2.0.0-alpha.8-2",
"@angular2-material/icon": "^2.0.0-alpha.8-2",
"@angular2-material/input": "^2.0.0-alpha.8-2",
"@angular2-material/list": "^2.0.0-alpha.8-2",
"@angular2-material/menu": "^2.0.0-alpha.8-2",
"@angular2-material/progress-bar": "^2.0.0-alpha.8-2",
"@angular2-material/progress-circle": "^2.0.0-alpha.8-2",
"@angular2-material/radio": "^2.0.0-alpha.8-2",
"@angular2-material/sidenav": "^2.0.0-alpha.8-2",
"@angular2-material/slide-toggle": "^2.0.0-alpha.8-2",
"@angular2-material/slider": "^2.0.0-alpha.8-2",
"@angular2-material/tabs": "^2.0.0-alpha.8-2",
"@angular2-material/toolbar": "^2.0.0-alpha.8-2",
"@angular2-material/tooltip": "^2.0.0-alpha.8-2",
"ng2-material-dropdown":"0.5.4",
"ng2-toasty": "^2.2.2",
"@types/hammerjs": "^2.0.30",
"angular2-cookie": "1.2.3",
"angular2-material-datepicker": "^0.5.0",
"angulartics2": "^1.1.9",
"core-js": "^2.4.1",
"d3": "^4.3.0",
"es6-shim": "0.35.1",
"ng2-datetime-picker": "^0.11.3",
"ng2-tag-input": "0.6.0",
"ng2-auto-complete":"0.8.2",
"reflect-metadata": "0.1.3",
"rickshaw": "^1.6.0",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23",
"ng2-file-upload": "^1.1.4-2",
"angular2-color-picker": "^1.3.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.16"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.21",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"typings": "1.3.1"
}
ng build -prod
was working fine, however all of a sudden the same configuration gives the following error
ERROR in ./src/styles.css
Module build failed: Error: Cannot find module '/Volumes/DATA/new- clone-test/nbw/node_modules/css-loader/index.js?sourcemap&minimize'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at loadLoader (/Volumes/DATA/new-clone-test/nbw/node_modules/loader-runner/lib/loadLoader.js:13:17)
I am not sure what causes this issue. Any help will be much appreciated.
回答1:
I have got the same issue as you. As a temporary solution I changed to 'ng build --dev'. Using this command the loader uses webpack-build-development.js instead of webpack-build-production.js and gets 'css-loader?sourcemap' instead of 'css-loader?sourcemap&minimize'.
回答2:
Thanks to Florinache!
Downgrading to angular-cli "1.0.0-beta.19-3" works for me. I had the same issue from today on in all my projects...
{
"devDependencies": {
...
"angular-cli": "1.0.0-beta.19-3",
...
}
}
回答3:
had the same issue starting today.
The solution I found was to change the angular-cli dependency in package.json file to "1.0.0-beta.19-3" and reinstall the npm packages.
{
"devDependencies": {
...
"angular-cli": "1.0.0-beta.19-3",
...
}
}
Hope this helps!
回答4:
It looks like extract-text-webpack-plugin is upgraded to RC, Try overriding the extract-text-webpack-plugin version to "2.0.0-beta.4" in your package.json.
回答5:
mkishorem is right.
I also got same error and fix with adding override code at package.json like below
"devDependencies": {
"extract-text-webpack-plugin": "2.0.0-beta.5"
}
no need to downgrading to angular-cli all.
回答6:
Update to @angular/* 2.3.1 version
来源:https://stackoverflow.com/questions/41889869/cannot-find-module-css-loader-while-doing-ng-build-prod-with-angular-cli1-0-0