Error "module build failed" when importing with @angular/cli
See original GitHub issueWhat MDC-Web Version are you using?
0.3.10
What browser(s) is this bug affecting?
All
What OS are you using?
Linux (Fedora 23), Node v6.11.0, npm v5.2.0
What are the steps to reproduce the bug?
Start an @angular/cli
project, install for instance @material/select
, and add following to styles.scss
.
@import '~@material/select/mdc-select';
Run project with npm start
What is the expected behavior?
It should compile fine.
What is the actual behavior?
The following error is output:
ERROR in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader?{"ident":"postcss"}!./~/@angular/cli/~/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/styles.scss
Module build failed:
@import "@material/animation/functions";
^
File to import not found or unreadable: @material/animation/functions.
Parent style sheet: /workspace/WISTWFU/wist-wfu-app/frontend/frontend-js/node_modules/@material/select/mdc-select.scss
in /workspace/WISTWFU/wist-wfu-app/frontend/frontend-js/node_modules/@material/select/mdc-select.scss (line 17, column 1)
@ ./src/styles.scss 4:14-215
@ multi ./~/primeng/resources/primeng.min.css ./src/styles.scss
webpack: Failed to compile.
Any other information you believe would be useful?
A simple modification of the mdc-select.scss
file makes it possible to import it correctly: Simply adding ~
to the package imports.
@import "~@material/animation/functions";
@import "~@material/typography/mixins";
@import "~@material/theme/mixins";
@import "~@material/rtl/mixins";
However I’m hesitant to submit my own pull request, since it would impact every component package.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
angular-cli 25.5 Module build failed - typescript - Stack Overflow
The error says the problem is in app.module. · Make sure you reference all your source files in the "include" and "files" sections...
Read more >Angular - Code with Mosh Forum
Error : Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js): · delete the node_modules folder · delete package-lock.json ...
Read more >Module build fails after importing mdb.scss - MDBootstrap
I installed the MDB5 ANGULAR UI KIT Pro Essential and after importing the scss to the styles.css file I get the error shown...
Read more >Angular compiler options
References created by the template compiler use this module name when importing symbols from the flat module. Ignored if flatModuleOutFile is false ....
Read more >Angular CLI: "Module not found: Error: Can't resolve..."
The problem. After upgrading one of my Angular applications, from version 5 to version 6, I tried to build it (using ng build...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yeelan0319 unfortunately this does not solve the problem for me, as I am using Angular CLI 😢 And that is actually what this issue is about.
Regarding the documentation: IMHO it’s missing specific information about how to configure Webpack. This seems to be exactly the line I mentioned from material-components’ own
webpack.config.js
file; modified for end-users I guess it would be something like:Why not include that directly in the README, instead of just a vague statement that
node_modules
needs to be in the Sass include path?Likewise for people using node-sass directly - IMHO it would be much more helpful to have a concrete code snippet.
This one worked for me on Angular 7.x:
You must nclude the same
stylePreprocessorOptions
onprojects.yourProjectName.architect.build.options
andprojects.YourProjectName.test.options
.