Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

What is the difference? Read these first - https://www.npmjs.com/package/node-sass/v/7.0.1 vs https://www.npmjs.com/package/sass

  1. Edit Delete package-lock.json then edit the package.json file, in theme root.

    1. Add or edit what you need. Here’s a helpful example with explanation: https://www.hook42.com/blog/nodejs-version-control-drupal-themes

  2. Run the following, suggested commands:

    1. npm cache clean --force

    2. nvm ls
      Prints the node versions installed on your machine & the current node version you're using.

    3. nvm use 16

    4. npm install

      1. If you try to run npm install however, it will error out due to you trying to use node-sass.

      2. npm uninstall node-sass

        1. Removes it node-sass

      3. npm install sass or npm i sass --save or npm install node-sass@npm:sass

        1. Replaces node-sass with the newer sass dependency.

    5. npm install

      1. Should run as expected, if not - follow the errors/warnings as resolve as needed. We have some note notes below on know known issues.

    6. npm cache clean --force

    7. If you run into a problem, and want to try again:

      1. rm -r node_modules
        This will remove the node_modules folder in your repository. If you are using Webpack, you can also remove the dist folder using rm -r dist and re-build your repository.

Note: If the commands are not automatically altering your package.json file, you may need to edit it manually.

...

Know issues, and Potential warning or errors known with changing Node to version 16 and Dart SASS:

  • Math changes required when using Dart Sass - Examples:

Code Block
// This:
@function strip-unit($num) {
  @return $num / ($num * 0 + 1);
}

// Should become this:
@use "sass:math";

@function strip-unit($num) {
  @return math.div($num, ($num * 0 + 1));
}

Code Block
// This:
$browser-context: 16;
@function rem($pixels, $context: $browser-context) {
  @return #{strip-unit($pixels)/$context}rem;
}

// Should become this:
@use "sass:math";

$browser-context: 16;
@function rem($pixels, $context: $browser-context) {
  @return #{math.div(strip-unit($pixels), $context)}rem;
}

Code Block
// These:
$base-space: 1rem; // 16px
$space-10: $base-space / 2; // 8px
$space-20: $base-space * 2; // 32px

// Should become like these:
$base-space: 1rem; //16px
$space-10: calc($base-space / 2); // 8px
$space-20: calc($base-space * 2); // 32px