【问题标题】:AngularJS ng serve error failed to compile error in node modules/css-loaderAngularJS ng 服务错误未能在节点模块/css-loader 中编译错误
【发布时间】:2018-02-20 12:50:36
【问题描述】:

我之前在开发 Angular 项目时没有遇到过这种情况。我在这个项目中使用了 angular 2。这是我在项目目录中运行命令 ng serve 时出现的错误。

chunk {chartjs.module} chartjs.module.chunk.js, chartjs.module.chunk.js.map () 13.6 kB {main} [rendered] 块 {components.module} components.module.chunk.js, components.module.chunk.js.map () 268 kB {main} [rendered] 块 {dashboard.module} 仪表盘.module.chunk.js, dashboard.module.chunk.js.map () 64.5 kB {main} [rendered] 块 {icons.module}icons.module.chunk.js,icons.module.chunk.js.map() 184 kB {main} [rendered] 块 {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered] chunk {main} main.bundle.js, main.bundle.js.map (main) 82 kB {vendor} [初始] [渲染] 块 {pages.module} pages.module.chunk.js, pages.module.chunk.js.map () 18.5 kB {main} [rendered] 块 {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 328 kB {inline} [initial] [rendered] chunk {scripts} scripts.bundle.js,scripts.bundle.js.map(脚本)358 kB {内联} [初始] [渲染] 块 {styles} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {inline} [初始] [渲染] 块 {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.53 MB [初始] [渲染] 块 {widgets.module} widgets.module.chunk.js, widgets.module.chunk.js.map () 58.5 kB {main} [渲染]

错误 ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./node_modules/sass-loader/lib/ loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/scss/style.scss 模块构建失败:错误:ENOENT:没有这样的文件或目录,scandir '/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/vendor' 在错误(本机) 在 Object.fs.readdirSync (fs.js:952:18) 在 Object.getInstalledBinaries (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/lib/extensions.js:124:13) 在foundBinariesList (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/lib/errors.js:20:15) 在 foundBinaries (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/lib/errors.js:15:5) 在 Object.module.exports.missingBinary (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/lib/errors.js:45:5) 在 module.exports (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/lib/binding.js:15:30) 在对象。 (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/node-sass/lib/index.js:14:35) 在 Module._compile (module.js:570:32) 在 Object.Module._extensions..js (module.js:579:10) 在 Module.load (module.js:487:32) 在 tryModuleLoad (module.js:446:12) 在 Function.Module._load (module.js:438:3) 在 Module.require (module.js:497:17) 在需要(内部/module.js:20:19) 在对象。 (/home/jayzdevera/Documents/ad-fingerprinting/web/node_modules/sass-loader/lib/loader.js:3:14) @ ./src/scss/style.scss 4:14-195 @multi ./src/scss/style.scss

webpack:编译失败。

我的节点 v 是 8.4.0

如果有人可以提供帮助将不胜感激。 提前致谢。

【问题讨论】:

  • 尝试删除node_modules目录并重新安装所有内容
  • 我已经试过了。但它没有锻炼。

标签: javascript angularjs node.js


【解决方案1】:

我自己找到了解决这个问题的方法。 下面的链接与我有同样的错误。 https://github.com/JeffreyWay/laravel-mix/issues/226

只需运行 npm install node-sass

如果运行 npm install node sass 时出现问题,请运行此命令。

npm install node-sass --no-bin-links

它解决了我的问题。

【讨论】:

    【解决方案2】:
    Try including the built version of chart.js:
    
    "scripts": ["../node_modules/chart.js/dist/Chart.bundle.min.js"],
    
    or you need to add the path to your .angular-cli.json like this:
        "apps": [
    
            "scripts": [
    
                "../node_modules/chart.js/src/chart.js",
    
            ],
    
        ]
    

    【讨论】:

      猜你喜欢
      • 2019-05-02
      • 2019-09-23
      • 2021-12-30
      • 2018-04-20
      • 2018-02-18
      • 1970-01-01
      • 2016-05-29
      • 1970-01-01
      • 2022-12-16
      相关资源
      最近更新 更多