ANGULAR: ModuleBuildError: Module build failed.

Dung Do Tien Apr 12 2021 434

Hi Guys, I have an application built with Angular 7. I still build it well but when I get source code from GIT to other the computer and build source code with ng build --c=staging command I got an error: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):

ERROR in ./src/scss/style.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Missing binding E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\node-sass\vendor\win32-x64-64\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 10.x

Found bindings for the following environments:
  - Windows 64-bit with Node.js 12.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
    at module.exports (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\node-sass\lib\binding.js:15:13)
    at Object.<anonymous> (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\node-sass\lib\index.js:14:35)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.sassLoader (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\sass-loader\lib\loader.js:46:72)
    at runLoaders (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\webpack\lib\NormalModule.js:301:20)
    at E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:367:11
    at E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:233:18
    at runSyncOrAsync (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:143:3)
    at iterateNormalLoaders (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:205:4
    at VirtualFileSystemDecorator.readFile (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\@ngtools\webpack\src\virtual_file_system_decorator.js:39:13)
    at processResource (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:202:11)
    at iteratePitchingLoaders (E:\Project\Mexico\CMS\Source\automexico\DVG.APA.CMSClient\node_modules\loader-runner\lib\LoaderRunner.js:158:10)

This is the config build command in my pakage.json file:

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod --staging --uat --aot --buildOptimizer --commonChunk --vendorChunk --optimization --progress",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "build-prod": "ng build --prod --output-path=dist/prod",
    "build-uat": "ng build --c=uat --output-path=dist/uat",
    "build-testing": "ng build --c=staging --output-path=dist/staging"
  },

And below is my environment:

Angular CLI: 7.3.6
Node: 10.16.0
OS: win32 x64
Angular: 7.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.6
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.6
@angular-devkit/schematics        7.3.6
@angular/cdk                      7.3.3
@angular/cli                      7.3.6
@angular/material                 7.3.3
@ngtools/webpack                  7.3.9
@schematics/angular               7.3.6
@schematics/update                0.13.6
rxjs                              6.5.3
typescript                        3.2.4
webpack                           4.29.0

Please tell me how can I resolve it?

Have 1 answer(s) found.
  • M

    Marry Christ Apr 12 2021

    I got the same error as you. You can try some step below to resolve it:

    1. Install npm by using npm install command.

    2. Try more update npm by using npm update command.

    3. Rebuild Node SASS by using npm rebuild node-sass command.

    4. Try again to build your app one more time!!!

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close