Versions Compared

Key

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

...

Changing your project to use Dart SASS with Node 16

If you are updating an existing Node 14 project, that uses npm node-sass, you will need to make a few changes before updating to Node 16 and npm sass.

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 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

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

        1. Replaces node-sass with the newer sass

    5. npm install

      1. Should run as expected, if not - follow the errors/warnings as resolve as needed. We have some note below on know 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.

      If you are updating an existing Node 14 project, that uses npm node-sass, you will need to make a few changes before updating to Node 16 and npm sass.

    8. 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

    9. Node-Sass

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

  • Node-Sass - Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.

  • Are you running a M1 mac? ARM64 isn't supported by any version of node-sass right now.

...

  • If you try to run npm install after switching to Node 16 - it will error out

...

  • npm uninstall node-sass

  • npm install sass or npm i sass --save or npm install node-sass@npm:sass

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

  • . See above for details.

...