构建用于生产的Angular 4应用程序的css-loader出错

时间:2017-12-21 12:39:10

标签: angular angular-cli

我可以使用' ng build'编译和构建应用程序,但是当我尝试运行' ng build --prod --aot=false'为了生产它,我得到一个非常令人困惑的错误,即:

  

devrep @ dev-laptop:〜/ Documents / projects / FWP $ ng build --prod   --aot = FALSE        11%构建模块9/14模块5活动... font-awesome / css / font-awesome.min.cssNode#moveTo已弃用。   使用Container#append。       日期:2017-12-21T12:09:04.162Z
      哈希:4aab95fe772649d00bd9       时间:64798ms       chunk {0} polyfills.87365c933937cb2f588a.bundle.js(polyfills)65.8 kB [initial] [rendered]       chunk {1} main.7c8cba86955be3d0b56d.bundle.js(main)687 kB [initial] [rendered]       chunk {2} styles.6794b28885d6e9fad13b.bundle.css(styles)170 kB [initial] [rendered]       chunk {3} vendor.e43732721f7d20b3cde5.bundle.js(vendor)771 kB [initial] [rendered]       chunk {4} inline.d266a3c997900449849a.bundle.js(inline)1.45 kB [entry] [rendered]

ERROR in ./src/app/integralui/css/integralui.module.css
Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve './.' in
     

' /家庭/ devrep /文件/项目/ FWP / SRC /应用程序/ integralui / CSS'           在factoryCallback(/home/devrep/Documents/projects/FWP/node_modules/webpack/lib/Compilation.js:276:40)           在工厂(/home/devrep/Documents/projects/FWP/node_modules/webpack/lib/NormalModuleFactory.js:35:20)           解析器(/home/devrep/Documents/projects/FWP/node_modules/webpack/lib/NormalModuleFactory.js:60:20)           在asyncLib.parallel(/home/devrep/Documents/projects/FWP/node_modules/webpack/lib/NormalModuleFactory.js:127:20)           at /home/devrep/Documents/projects/FWP/node_modules/async/dist/async.js:3861:9           at /home/devrep/Documents/projects/FWP/node_modules/async/dist/async.js:421:16           at iteratorCallback(/home/devrep/Documents/projects/FWP/node_modules/async/dist/async.js:996:13)           at /home/devrep/Documents/projects/FWP/node_modules/async/dist/async.js:906:16           at /home/devrep/Documents/projects/FWP/node_modules/async/dist/async.js:3858:13           at resolvers.normal.resolve(/home/devrep/Documents/projects/FWP/node_modules/webpack/lib/NormalModuleFactory.js:119:22)           在onError(/home/devrep/Documents/projects/FWP/node_modules/enhanced-resolve/lib/Resolver.js:65:10)           在loggingCallbackWrapper(/home/devrep/Documents/projects/FWP/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)           在runAfter(/home/devrep/Documents/projects/FWP/node_modules/enhanced-resolve/lib/Resolver.js:158:4)           在innerCallback(/home/devrep/Documents/projects/FWP/node_modules/enhanced-resolve/lib/Resolver.js:146:3)           在loggingCallbackWrapper(/home/devrep/Documents/projects/FWP/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)           在下一个(/home/devrep/Documents/projects/FWP/node_modules/tapable/lib/Tapable.js:252:11)        @ ./src/app/integralui/css/integralui.module.css        @ multi ./src/styles.css ./src/assets/zurb-foundation/foundation-prototype.min.css   ./src/assets/fwcIcons-font/css/fwcIcons.css   ./src/assets/fwcMenuIcons-font/css/fwcMenuIcons.css   ./src/app/integralui/css/integralui.module.css   ./node_modules/font-awesome/css/font-awesome.min.css   ./node_modules/ng2-toastr/bundles/ng2-toastr.min.css       ERROR在./node_modules/css-loader?{"sourceMap":false,"importLoaders" ;:1}!./node_modules/postcss-loader/lib?{"ident& #34;:" postcss""插件":[NULL,NULL,NULL,{"版本":" 5.2.18&#34 ;, "插件":[NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL]," postcssPlugin":" cssnano"" postcssVersion&#34 ;: " 5.2.18"}]," sourceMap":假} ./ SRC /应用/ integralui / CSS / integralui.grid-default.css!       找不到模块:错误:无法解决' ./.'在' / home / devrep / Documents / projects / FWP / src / app / integralui / css'       解决' ./.'在' / home / devrep / Documents / projects / FWP / src / app / integralui / css'         使用描述文件:/home/devrep/Documents/projects/FWP/package.json(相对路径:   ./src/app/integralui/css)           Field'浏览器'不包含有效的别名配置         使用描述文件后:/home/devrep/Documents/projects/FWP/package.json(相对路径:   ./src/app/integralui/css)           使用描述文件:/home/devrep/Documents/projects/FWP/package.json(相对路径:   ./src/app/integralui/css)             没有延期               Field'浏览器'不包含有效的别名配置               / home / devrep / Documents / projects / FWP / src / app / integralui / css不是文件             .TS               Field'浏览器'不包含有效的别名配置               /home/devrep/Documents/projects/FWP/src/app/integralui/css.ts没有   存在             .js文件               Field'浏览器'不包含有效的别名配置               /home/devrep/Documents/projects/FWP/src/app/integralui/css.js没有   存在             作为目录               现有目录                 使用路径:/ home / devrep / Documents / projects / FWP / src / app / integralui / css / index                   使用描述文件:/home/devrep/Documents/projects/FWP/package.json(相对路径:   ./src/app/integralui/css/index)                     没有延期                       Field'浏览器'不包含有效的别名配置                       /家庭/ devrep /文件/项目/ FWP / src目录/应用/ integralui / CSS /指数   不存在                     .TS                       Field'浏览器'不包含有效的别名配置                       /home/devrep/Documents/projects/FWP/src/app/integralui/css/index.ts   不存在                     .js文件                       Field'浏览器'不包含有效的别名配置                       /home/devrep/Documents/projects/FWP/src/app/integralui/css/index.js   不存在       [/家庭/ devrep /文件/项目/ FWP / src目录/应用/ integralui / CSS]       [/home/devrep/Documents/projects/FWP/src/app/integralui/css.ts]       [/home/devrep/Documents/projects/FWP/src/app/integralui/css.js]       [/家庭/ devrep /文件/项目/ FWP / src目录/应用/ integralui / CSS /索引]       [/home/devrep/Documents/projects/FWP/src/app/integralui/css/index.ts]       [/home/devrep/Documents/projects/FWP/src/app/integralui/css/index.js]        @ ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident&# 34;:" postcss""插件":[NULL,NULL,NULL,{"版本":" 5.2.18",& #34;插件":[NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL]" postcssPlugin":" cssnano"" postcssVersion":& #34; 5.2.18"}]," sourceMap":假} ./ SRC /应用/ integralui / CSS / integralui.grid-default.css   6:9668-9682        @ ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident&# 34;:" postcss""插件":[NULL,NULL,NULL,{"版本":" 5.2.18",& #34;插件":[NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL]" postcssPlugin":" cssnano"" postcssVersion":& #34; 5.2.18"}]," sourceMap":假} ./ SRC /应用/ integralui / CSS / integralui.grid.css        @ ./src/app/integralui/css/integralui.module.css        @ multi ./src/styles.css ./src/assets/zurb-foundation/foundation-prototype.min.css   ./src/assets/fwcIcons-font/css/fwcIcons.css   ./src/assets/fwcMenuIcons-font/css/fwcMenuIcons.css   ./src/app/integralui/css/integralui.module.css   ./node_modules/font-awesome/css/font-awesome.min.css   ./node_modules/ng2-toastr/bundles/ng2-toastr.min.css

我尝试过在Google上找到的一些解决方案,例如将所有CSS文件复制到' assets'文件夹或更新Angular CLI位,它没有做出改变。我无法理解他们所抱怨的内容以及无法找到'./.'模块的内容。

有任何线索吗?

我将node 9.3.0npm 5.6.0Angular CLI 1.6.2Angular 4.4.6一起使用。

谢谢!

2 个答案:

答案 0 :(得分:2)

问题是应用程序中使用的某个组件中的CSS文件不正确。这就是这一行:

background: url('') no-repeat 0 0;

我们错误地将URL留空了,似乎编译器无法为生产构建应用程序(尽管它可以完美地编译开发)。

干杯,

答案 1 :(得分:0)

请更新" @ angular / cli"到" 1.7.3"

  1. npm remove @ angular / cli
  2. npm cache clean --force
  3. npm install -g @ angular / cli @ 1.7.3
  4. 仍然卡住,然后用

    更新你的package.json
    @angular/cli": "1.7.3"
    

    然后运行npm install

    经过测试并为我工作