Error build Angular application: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):

Viewed 27

My build and deployment just suddenly stopped working for no reason. It was working a few months ago but now it is failing. Below is the error message.

ERROR in ./src/styles/global.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: Cannot find module 'node-sass'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.sassLoader (/opt/atlassian/pipelines/agent/build/node_modules/sass-loader/lib/loader.js:46:72)

This is the snippet of my bitbucket-pipelines.yml

image: node:8.9.0

pipelines:
  branches:
    master: # Build and deploy master branch
      - step:
          caches:
            - node
          script:
            - sh publish_version.sh
            - npm install
            - npm run build_production
          artifacts:
              - dist/**
      - step:
          name: Deploy to S3
          deployment: production
          image: atlassian/pipelines-awscli
          script: # Copy to S3
            - pwd
            - aws s3 sync --delete dist s3://production.mysite.com

This is the snippet of my bitbucket-pipelines.yml

This is what npm run build_production is : "build_production": "ng build --production --output-path=dist"

1 Answers

According to node-sass github page, the supported node.js versions vary release by release. enter image description here

Note: If you are using any background-url in src/styles/global.scss then make sure that the image must be in /asset folder with the relevant directory time if the image is not available then also this error will be thrown by angular.

Related