Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 2.27 KB

File metadata and controls

71 lines (50 loc) · 2.27 KB

Node.js Dependency Fix - node-sass to sass Migration

Issue

The project had node-sass as a dependency, which:

  • Requires Python 2 for building native bindings
  • Python 2 reached end-of-life and is no longer available on modern systems
  • Causes build failures with errors like: gyp verb check python checking for Python executable "python2"

Solution

Commit: [commit hash will be added]

Changes Made

  1. Removed node-sass from dependencies

    • node-sass v7.0.0 was removed from package.json
    • This package is deprecated and no longer maintained
  2. Added sass (Dart Sass) to devDependencies

    • sass v1.69.5 was added to package.json
    • Dart Sass is the official replacement for node-sass
    • No Python required - pure JavaScript implementation
    • Faster and more reliable

Why This Works

  • Angular 14 uses @angular-devkit/build-angular which includes support for Dart Sass
  • The project's SCSS files are compiled using Angular's build system, not node-sass directly
  • Dart Sass is backward compatible with node-sass syntax
  • @ionic/app-scripts still has node-sass as a transitive dependency, but it's not used since the project uses Angular CLI (ng commands)

Testing

The fix was verified by:

  1. Removing node-sass from package.json
  2. Adding sass to devDependencies
  3. Running npm install --legacy-peer-deps --ignore-scripts
  4. Running npm run build successfully

Build completes without errors and SCSS files are compiled correctly.

For Developers

If you encounter build issues related to node-sass or Python:

  1. Delete node_modules and package-lock.json:

    rm -rf node_modules package-lock.json
  2. Install dependencies:

    npm install --legacy-peer-deps --ignore-scripts
  3. Build the project:

    npm run build

The --ignore-scripts flag prevents chromedriver download issues in environments without internet access.

Future Improvements

Consider removing @ionic/app-scripts from devDependencies since:

  • The project uses Angular CLI exclusively
  • It's an older Ionic build tool no longer needed
  • It pulls in the old node-sass v4.14.1 as a transitive dependency

However, this removal should be done carefully with thorough testing to ensure no build scripts depend on it.